Skip to content

Instantly share code, notes, and snippets.

@wwwbruno
Last active September 15, 2017 20:14
Show Gist options
  • Save wwwbruno/98ece780a4e16a675fa7a9c578252ec5 to your computer and use it in GitHub Desktop.
Save wwwbruno/98ece780a4e16a675fa7a9c578252ec5 to your computer and use it in GitHub Desktop.
Fake pageview on RD Station Lead tracking
/* References
http://www.w3schools.com/js/js_cookies.asp
https://github.com/ResultadosDigitais/rdocs/blob/master/integracoes_html_puro.md */
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length,c.length);
}
}
return "";
}
function sendPageview(title, url) {
var token = 'rd-station-public-token', /* set your RD Station public token */
client_id = JSON.parse(decodeURIComponent(getCookie('rdtrk'))).id;
jQuery.post('https://pageview-notify.rdstation.com.br/send', { token: token, title: title, url: url, client_id: client_id } );
}
try { sendPageview('Fake page', 'http://yoursite.com/fake-page'); } catch(err) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment