简体   繁体   中英

Disable GTM tag firing when page loaded as an iFrame

I have been asked to implement Google Tag Manager for a site which loads another page (from the same site) as an iFrame.

I want to disable GTM on this page when it is loaded as an iFrame but work normally when a visitor goes to that page.

I can check with JS whether the page is loaded as an iFrame and thereby not load the GTM script content. However, is there a solution if JS is disabled (when the noscript part of the GTM code would ordinarily takeover)?

Have you tried a hostname filter in GTM? Basically, you'd have a rule in GTM that checks if the domain the code is executed on matches the domain you /want/ it to be executed on. If it does, your tag fires. If it doesn't, your tag doesn't fire.

Note that if the browser the GTM code is in doesn't execute JavaScript, the point is moot - you NEED JavaScript to run to track anything in GA, whether you've got something in NOSCRIPT tags or not.

When you insert the iframe add a parameter (ie "iframe=true") to the page url. Set up a blocking rule (v1) or trigger exception (v2) for your tags if the parameter is present (custom variable, type "URL", "component type" is "Query", "Query key" is the name of your parameter).

As pointed out in the other answer this is only relevant if you have any non-javascript tags in GTM (like custom images), most tags these days require javascript in any case (but then you probably know that).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM