Umut KIRGÖZ
Umut KIRGÖZ

Reputation: 2123

Push data to dataLayer and send it to Google Analytics at the same time in Google Tag Manager

I have a complicated issue with GTM, dataLayer and GA.

My setup is:

Problem is; GA is not including dataLayer changes made by custom Tag even if it's fired after Custom tag.

I noticed, dataLayer.push(...) creates a new GTM event named message.

How can I handle this, GA pageview tag must have the final dataLayer.

tHanks

Upvotes: 0

Views: 1114

Answers (1)

Eike Pierstorff
Eike Pierstorff

Reputation: 32780

The datalayer is not re-evaluated in a tag sequence. However you can manipulate the dataLayer directly.

First you need to make sure that the built-in "Container ID" variable is active (or you pass in the ID manually).

Then you get a reference to your GTM instance and call a dataLayer.set with a key and value:

var gtm = google_tag_manager[{{Container ID}}];
gtm.dataLayer.set('someKey',"someValue")

Unlike a dataLayer.push this will be available in the next step in the sequence.

Upvotes: 1

Related Questions