Skip to content

Instantly share code, notes, and snippets.

@lcrespilho
Last active August 9, 2017 20:46
Show Gist options
  • Save lcrespilho/654957db2669a806cfdb37663cb9d69b to your computer and use it in GitHub Desktop.
Save lcrespilho/654957db2669a806cfdb37663cb9d69b to your computer and use it in GitHub Desktop.
<script>
// somente dispara o pixel do facebook se a origem for Natura
if (document.referrer.indexOf('consultoria.natura.com.br') >= 0) {
// grava o cookie racc_origin=natura do domínio geekie.com.br por 7 dias,
// para capturar o cadastro final se este não for realizado na mesma sessão.
document.cookie = 'racc_origin=natura; expires=' + new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toUTCString() + '; domain=geekie.com.br; path=/;';
/*
monta o pixel do facebook manualmente. Equivale a:
fbq('init', '235391240155676');
fbq('track', 'PageView', { 'site_name': 'Geekie' });
*/
var urlPixel = 'https://www.facebook.com/tr/?id=235391240155676&ev=PageView&dl=' + encodeURIComponent(document.location.href) + '&rl=' + encodeURIComponent(document.referrer) + '&if=false&ts=' + Date.now() + '&cd%5Bsite_name%5D=Geekie&v=2.7.19&ec=0&o=28';
var pixel = document.createElement('img');
pixel.width = '1';
pixel.height = '1';
pixel.style.display = 'none';
pixel.src = urlPixel;
document.body.appendChild(pixel);
}
</script>
@lcrespilho
Copy link
Author

Local de instalação da tag
Em qualquer lugar do <body> da página, mas de preferência no topo.

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