0
votes

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

My setup is:

  • GA tag is triggered in PageView with Enhanced Ecommerce enabled by using dataLayer
  • A Custom HTML tag which pushes an item to dataLayer, and it's configured to run just before the GA tag (by using tag sequencing)

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

1

1 Answers

1
votes

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.