Highlighted

How to suppress events on page load and have them fired only when the button is clicked?

pallavi_roy
Visitor
pallavi_roy

Hi,

Is there a javascript that we can use to suppress event call on page load?

The below extension is not working for me -

try{

  if(b._utag_event === 'link' && typeof b.EventType !== 'undefined' && (b.EventType === 'TipExpand’ || b.EventType === 'NutritionExpand’) ){

    return false;

  }

}

catch(e){

  utag.DB(e);

};

Regards,

Pallavi

2 REPLIES 2

How to suppress events on page load and have them fired only when the button is clicked?

james_white_224
Visitor
james_white_224

Are you sure it's not utag.view() or maybe utag.link() you want to run this code through?  As far I know the b Object is only a copy and is not global. It also sounds like you want to impact an action post page load. According to the b Object documentation:

"...on subsequent tracking calls that occur after the page load, the b object is a copy of the object passed to utag.view() or utag.link() and does not contain variables from the origial on-page data object. However, you can preserve data from utag_data in tracking calls (per page load) by using the Base Variables setting in the publish settings..."

https://community.tealiumiq.com/t5/JavaScript-utag-js/The-b-Object/ta-p/13620

Hope that helps.

How to suppress events on page load and have them fired only when the button is clicked?

BenStephenson
Contributor
BenStephenson Contributor

Hi

You can use the a object for this.

The a object is the type of event, and is a string set to either "link" or "view".

We have quite a lot of JS extensions that open with 

if( a === "link" ) { ... }

or

if( a === "view" ) { ... }
Checkout our blog: www.120feet.com/blog