2

We need to push events to GTM. Typically this is done via JavaScript using the datalayer as described here using:

<a href="#" name="button1" onclick="dataLayer.push({'event': 'button1-click'});" >Button 1</a>

What I want to know is:

  1. Whether the above is possible using the REST API for this as also asked in the SO post?
  2. Is there any client side session info (eg IP address, browser etc.) captured using the JS approach as part of the GTM call?
Community
  • 1
  • 1
TheEdge
  • 9,291
  • 15
  • 67
  • 135

1 Answers1

4

Update: Google by now supports server-side tag management. While SSGTM is not a Rest Api in any formal sense, you can send data there via an http endpoint.

--

  1. If by the REST API you mean the Google Tag Manager API then no, this is for GTM configuration only.

GTM for web pages is not run on the server in any case - it bundles the configured tags into a Javascript function that is evaluated and executed in the client, so there is nothing you could push the data to. And while it is vaguely possible you could reverse engineer the network calls from the Mobile SDK (mobile GTM is pretty much a different product with the same name) there is no supported API outside the platform specific SDKs.

  1. GTM (for web) can evaluate everything that can be retrieved via Javascript. So browser yes (via the navigator object), but no IP addresses, no http headers etc.
Eike Pierstorff
  • 31,996
  • 4
  • 43
  • 62
  • For 2) is it possible to push an event? i.e Is it possible to get the same result as via the dataLayer.Push()? – TheEdge Jun 16 '16 at 22:27
  • You cannot evaluate Javascript in GTM without a (native or custom) event since you need an event to make GTM evaluate the Javascript (the "dataLayer.push" is not native code, it's overloaded with a method that tells GTM to update its internal data model). So if I understand your question correctly the answer would be "no". – Eike Pierstorff Jun 17 '16 at 08:32