3

I am trying to use GTM for my website. I have initialized the dataLayer variable like this:

dataLayer = [{
'pageCategory': 'signup',
'visitorType': 'high-value'
}];

Now I have triggered the request to gtm.js Now, I make another push to my dataLayer onclick of a button.

<a href="#" onclick="dataLayer.push({'event': 'GAEvent','pageURL': '/link-click/'});">Click Here...</a>

I could see that the dataLayer variable is appended tothe new object . However, I could not see any request being triggered to GTM portal in my console. I am not able to understand How, the new object(pushed during click event) is communicated to the GTM portal?

Vivek S
  • 5,384
  • 8
  • 51
  • 72
  • Once the `gtm.js` script has loaded asynchronously, `dataLayer` which used to be a plain old Array gets replaced with an Object with a new `push()` method which executes in realtime instead of queuing for later use – Mike Causer Jan 20 '14 at 11:43
  • Inside GTM you need to have a `Tag`, eg. Google Analytics, which has a `Firing Rule` that listens for a `Macro` using the `DataLayer Variable` GAEvent which equals a value, contains, regex match etc. – Mike Causer Jan 20 '14 at 11:45

1 Answers1

-1

It isn't.

Everything you configure in the GTM interface is packed into a javascript function, embedded into your page and evaluated/executed in the scope of your page. Once the GTM script has loaded it is not necessary to transmit anything to the GTM site.

Eike Pierstorff
  • 31,996
  • 4
  • 43
  • 62
  • Interesting that this answer is accepted. Yes it should be transmitted. If everything works fine and you look at the network requests, you can see the network requests firing. OP seems to have had a problem with his network requests not firing. Mike causer's comments explain it better than this answer imho. – Stijn de Witt Jan 25 '15 at 13:52
  • @StijndeWitt, the OP asked how stuff is transmitted to the GTM portal. It is not. It is pulled from the GTM portal as a javascript function and then the contained pixels fire to their respective goals, but the GTM script does not request anything to Google apart from the inital request. What ever you think you see, it's not the GTM script fetching another tag from Google. – Eike Pierstorff Jan 25 '15 at 15:22