Skip to content

Instantly share code, notes, and snippets.

@jsn789
Last active April 24, 2018 11:33
Show Gist options
  • Save jsn789/5460b7a7f884a96553d4570263f129ef to your computer and use it in GitHub Desktop.
Save jsn789/5460b7a7f884a96553d4570263f129ef to your computer and use it in GitHub Desktop.
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
}
return cd;
}catch(e) {
return cd = e.message;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment