Skip to content

Instantly share code, notes, and snippets.

@antonromanov
antonromanov / facebook-tracking
Last active March 10, 2023 16:49
facebook-tracking
<!-- Facebook All Pages -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', {{WCA}});
fbq('track', "PageView", {
@antonromanov
antonromanov / gist:2d0334aa1517d1bf0934
Created January 20, 2016 16:09
Save utm_term value in the cookie
(function() {
//if the cookie value is not equal regex utm_term, then create a 'atlas_utm_term' cookie
if (Cookies.get('atlas_utm_term')!== RegExp('/utm_term/')){
//1.split the search array into utm parameters
var utmArray = document.location.search.split("&");
//2.remove the '?' from the values of the array
utmReplace1 = utmArray.replace(function myFunction (utmReplace2) {return utmReplace2.filter(/./.test, /?/);}),'');
//3. set the value of the cookie
utmVar = utmReplace1.RegExp('/utm_term/')
//3. create a cookie with the value of the utm_term