Fire GTM tag only if on homepage of the site

南楼画角 提交于 2019-12-22 10:55:22

问题


The homepage can also have extra GET params (e.g. utm tags and similar marketing variables). How can I make it work? Simple "end with http://example.com or http://example.com/" doesn't work cause the url might be http://example.com/?utm_campaign=text&...

Thanks!


回答1:


The best practice is always install the GTM along you domain and execute it whenever you need. To launch a tag only in the home you need to use the following trigger. Add this on you custom HTML tag, take care of the equals.




回答2:


I know this is an old thread; but I found it after I solved this myself. I created a trigger for Page Path matches RegEx and used:

^\/(\?(.*))?$

What that does is matches for ONLY the hostname with no path (www.domain.com/) OR matches if a ? follows the /.

Might be another way to do this. Completed trigger:




回答3:


I've achieved the same using Page Path matches RegEx

^\/$|^\/\?

This means: match a string that begins (^) and ends ($) with / OR (|) that begins with /?

\ precedes special characters to denote that they should be treated as text and are not part of the expression.



来源:https://stackoverflow.com/questions/38430564/fire-gtm-tag-only-if-on-homepage-of-the-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!