Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created November 14, 2011 04:31
Show Gist options
  • Save mehdimehdi/1363236 to your computer and use it in GitHub Desktop.
Save mehdimehdi/1363236 to your computer and use it in GitHub Desktop.
fire _ptq.push after 5 page views
var ptReady = ptReady || [];
ptReady.push(function(){
PT.event.bind('dom.ready', function(){
var route, c = PT.cookie.get('_ptroute');
if (c){
route = PT.serializer.jsonDecode(c);
} else {
route = [];
}
if (PT.util.indexOf(route, window.location.pathname) == -1){
route.push(window.location.pathname);
}
if (route.length == 5){
_ptq.push(['view', 1]);
}
if (route.length <= 5){
PT.cookie.set('_ptroute', PT.serializer.jsonEncode(route));
}
});
});
@fgaudin
Copy link

fgaudin commented Nov 13, 2012

var ptReady = ptReady || [];
ptReady.push(function(){
    PT.event.bind('dom.ready', function(){
        var route, c = PT.cookie.get('_ptroute');
        if (c){
            route = PT.serializer.jsonDecode(c);
        } else {
            route = [];
        }
        if (PT.util.indexOf(route, window.location.pathname) == -1){
            route.push(window.location.pathname);
        }
        if (route.length == 5){
            _ptq.push(['view', 1]);
        }
        if (route.length <= 5){
            PT.cookie.set('_ptroute', PT.serializer.jsonEncode(route));
        }
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment