Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created November 14, 2012 22:14
Show Gist options
  • Save mehdimehdi/4075232 to your computer and use it in GitHub Desktop.
Save mehdimehdi/4075232 to your computer and use it in GitHub Desktop.
reward users for multiple 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));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment