Limiting GTM Tags to Mobile or Optimize experiments

Posted by: Josh Quenga Date Posted: April 25, 2023
Back to Case Studies

Issue

  • client was seeing over-reporting of tel: clicks likely from desktop

Solution

  • used a Custom JS variable to check if a DOM element was visible or not using checkVisibility()
  • updated trigger to only fire when the variable was equal to 1

Achievement

  • updated tel: link trigger to only fire on mobile when the sticky footer is visible

Snippet/Screenshot/Link

function(){
if(document.querySelector(‘.js-header-mobile’).checkVisibility()){
return ‘1’;
}
return ‘0’;
}