问题
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