Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

wordpress - Events not firing with UA and GTM - event equals gtm.js condition is not matched

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: Rule setup:

Event tracking setup: event setup:

Message pushed to data layer on click: data layer:

Firing rules: data layer:

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...