1

I'm currently working on a Server-Side Google Tag Manager (sGTM) setup where I aim to handle user consent checks on the server side.

Setup Details:

  • Consent Management: Handled by UserCentrics.

  • GA4 Configuration: There's a GA4 config tag that sends a page_view event to sGTM on a dataLayer update event named "consent_status".

Problem Description:

  1. Initial Visit:

    • When a user arrives at the website, the dataLayer is initialized with default values, triggering the first consent_status event.

    • The website sends a page_view to sGTM, which fires a tag to send data to an internal API.

    • At this point, no consent has been given yet, and we do not store personalized data.

  2. After Consent is Granted:

    • When the user gives consent, the GA4 config tag fires a page_view event again without waiting for the consent_status event.

    • However, sGTM fires the tags that should send data to GA4, Google Ads, etc., but there is no outgoing traffic.

    • Screenshot illustrating the issue

    • Then the consent_status event occurs again, this time with updated consent (all granted).

    • The GA4 config tag sends out the page_view event again, but here the info about the first_visit is missing.

    • At this point, the tags on the sGTM side fire as expected.

  3. Conclusion:

    • This means that three page_view events arrive at sGTM, but only the first (without consent) and the third (with consent update via dataLayer) are handled appropriately by sGTM by sending outgoing requests to Google Analytics. The second page_view event fires tags but results in no outgoing traffic.

Attempted Solution:

  • The only workaround I've found is to create a trigger that fires the GA4 config tag only when consent has been granted. But this isn't our preferred approach—we want the consent check to occur on the server side, not the client side.

Expected Behavior:

  • I expect sGTM to react to every GA4 tag appropriately and send a request to the Google Analytics API, handling consent on the server side.

Questions:

  • Has anyone faced the same issue and knows how to resolve it?

  • Could there be something I've missed in my configuration?

  • Is there any additional information you need that I haven't provided?

Any insights or suggestions would be greatly appreciated!

EDIT:

So we came up with following solution. It seems to work for now.

The Google Tag now fires only on two events

  1. consent_status - when the consent mode is pushed to the datalayer AND the consent is updated
  • normally the consent_status is fired 2 times. 1st when the consent is initialized and 2nd after the user has consent granted oder denied.
  1. user_engagement - when the datalayer gets the consent->update push. The user_engagement event is the situation when the user clicks the cookie banner.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.