This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Script to persists the listed querystring parameters across the length of the session. | |
(function() { | |
var domainsToDecorate = [ | |
'exampledomain.com' //add or remove domains (without https or trailing slash) | |
], | |
queryParams = [ | |
'utm_medium', //add or remove query parameters you want to transfer | |
'utm_source', | |
'utm_campaign', | |
'utm_adgroup', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Add Google Tag Manager javascript code as close to | |
the opening <head> tag as possible | |
=====================================================*/ | |
function add_gtm_head(){ | |
?> | |
<!-- Google Tag Manager --> | |
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | |
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | |
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> | |
<script> | |
/* jQuery is required for this script. | |
*/ | |
/// load jQuery in no-conflict mode | |
jQuery.noConflict(); | |
(function($) { | |
/// dom ready | |
$(function() { | |
$('body').on('click', function(e){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() { | |
//Credit to Simo Ahava | |
//https://www.simoahava.com | |
var url = {{Page URL}} | |
if(url == "specific domain you are interested in") | |
{ | |
// Replace newTrackingId value with the UA property to which you want to duplicate hits | |
var newTrackingId = 'UA-XXXXX-Y'; | |
var globalSendTaskName = '_' + newTrackingId + '_originalSendTask'; | |
return function(customModel) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// Set the timeout for when the dataLayer history should be purged. The default is 30 minutes. | |
// The timeout needs to be in milliseconds. | |
var timeout = 30*60*1000; | |
// Change dataLayerName only if you've defined another named for the dataLayer array in your | |
// GTM container snippet. | |
var dataLayerName = 'dataLayer'; | |
// Don't change anything below. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() { | |
try { | |
// Option1 or Option2 | |
cd = 'undefined' | |
if({{customVarOption1orOption2}} == 1){ | |
cd = '-'; //option1 | |
} | |
else if({{customVarOption1orOption2}} == 2){ | |
cd = '-'; // option2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Use as a variable in the "Non-interaction Hit" field of the Event Tag | |
function(){ | |
nonInteraction = 'Not Set' | |
//the height of the browser window's viewport | |
//https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight | |
windowHeight = window.innerHeight | |
//the height of the document object. In most cases, this is equal to the <body> element of the document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Use as Event Action | |
function(){ | |
pageHeight = 'Not Set', | |
//the height of the browser window's viewport - alternative is window.innerHeight | |
//https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight | |
windowHeight = window.innerHeight | |
//the height of the document object. In most cases, this is equal to the <body> element of the document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() { | |
// Example url: https://website.com/2015/10/File-Name.pdf | |
return {{Clicks - URL Path}}.split("/").slice(-1).join().split(".").shift(); | |
// Returns: File-Name | |
} |
NewerOlder