bpstrngr
bpstrngr

Reputation: 419

Why does my Data Layer Variable return the event name, instead of the value of the key given?

I want to use the value of the "user_id" field on my data layer in my Configuration Tag.
So, I created a Data Layer Variable, which as the tooltip says, will receive exactly that:
enter image description here

I have confirmed in Preview Mode, that the key on the dataLayer gets set correctly, and never overwritten:
enter image description here

Under my GA4 Configuration Tag, in "Fields to set", I pass this Data Layer Variable
for Google Analytics to receive it from Event Tags that use this configuration.
("Example 1: To set a user ID, add a row to Fields to Set. Set the Field Name to user_id, and the Value to a Tag Manager Variable that returns the user ID.")
There, it is defined as a "User Property" by the same name ("user_id"), which receives this value for reporting.
(as instructed in the best, and recent guide I found out there ("Let's Set It Up", step 3.), although even that is already outdated (eg. "GA4 Configuration" is still called by its old name "Google Analytics: App+Web Configuration"), and doesn't reveal his DLV setup specifically...)
enter image description here enter image description here

Yet in my Real Time view, under "users by users property", I end up seeing "gtm.js", ie. the name of the "Container Loaded" event which is set before the "user_id" field is pushed to the dataLayer (that's why you see it on the second screenshot):
enter image description here

When I replace the Data Layer Variable in the configuration with a static value,
that shows up in the Real Time view verbatim, so this DLV must be the culprit. Is this a bug in my Data Layer Variable?

Upvotes: 1

Views: 1072

Answers (1)

bpstrngr
bpstrngr

Reputation: 419

So at long last it turned out, that since the configuration tag was fired by the Page View event, that happened before I pushed the user_id to the dataLayer, and it filled the not-yet-existing value with the actual event name instead.

So I gave the user_id event a name to create a new custom event trigger, that now re-triggers the configuration tag, and this way the user_id-s are finally forwarded.

Upvotes: 1

Related Questions