Skip to content

Instantly share code, notes, and snippets.

@jsn789
jsn789 / non-Interaction-determinant.js
Last active April 11, 2018 09:16
GTM Custom JavaScript Variable For Scroll Tracking - non-Interaction logic
//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
@jsn789
jsn789 / customjs-error-handlig.js
Last active April 24, 2018 11:33
GTM Custom JavaScript - Error Handling. Used in a case where a custom js variable returns a value for a Custom Dimension. Used it for temporary troubleshooting.
function() {
try {
// Option1 or Option2
cd = 'undefined'
if({{customVarOption1orOption2}} == 1){
cd = '-'; //option1
}
else if({{customVarOption1orOption2}} == 2){
cd = '-'; // option2
}