问题
I've setup a Wordpress log and am using Google Tag Manager and Universal Analytics. I'm trying to track a bunch of events - all of which are outbound links. I've setup the link listener and the event code itself within GTM and tested it on github. However when I push it to the live site the events don't fire. I can track pageviews fine but the events are not being captured.
I've debugged it as best I can and what I can see is that they're not firing because not all the conditions are being met. Specifically for some reason the gtm.js is not being pushed to the data layer.
Have included images of my setup. The site is http://notthatsamfox.com
Rule setup:
Event tracking setup:
Message pushed to data layer on click:
Firing rules:
回答1:
I just took a look at your source code, and noticed that the GTM container is at the bottom, just before your closing body tag. The container should be placed just after the opening body tag, and not at the end. Try that and see if you get any results.
Quickly glancing at your setup, everything looks good.
回答2:
It looks like you may have already solved your problem but for anyone else who is finding that gtm.js appears not to be firing, check to make sure that your dataLayer initialization,
datalayer = [{"stuff":"here"}]
is above the Google Tag Manager Container:
<!-- Google Tag Manager -->
...
<!-- End Google Tag Manager -->
<script>
dataLayer = [{
'pageCategory': 'signup',
'visitorType': 'high-value'
}];
Otherwise, initializing the dataLayer below the container will overwrite the GTM dataLayer. The docs on this are here: https://developers.google.com/tag-manager/devguide#datalayer
回答3:
Use at the rule, the firing event gtm.dom.
{{event}} equals gtm.dom
来源:https://stackoverflow.com/questions/24581005/events-not-firing-with-ua-and-gtm-event-equals-gtm-js-condition-is-not-matched