Passing Consent in Your GTM Server-side Container

Loïc
Loïc
  • Updated

If you have implemented server-side tracking via GTM, you may be wondering how to make these data transmissions compliant with Axeptio.

In this documentation, we will see how to transmit Axeptio consent from your client container to your server container, so that you can condition your server tags based on it.

  1. Send consent information
  2. Condition the tags in your server container

1. Send consent information

First, we need a tag in the server container whose job is to send consent information to the server container whenever consent is modified.

 

For this, you will need the “Axeptio Consent State” variable available in the gallery. You can find documentation on how to create this variable here:

How to create the Axeptio variable

This variable contains the list of all accepted cookies, and this is what we will send to the server container. This is the equivalent of the dataLayer variable "axeptio_authorized_vendors".

 

To do this, we will create a tag that will handle sending this information.

In this case, I am using GA4 to send information to the server container, but there are other alternatives if you prefer.

In my GA4 configuration tag, I added a “server_container_url” parameter with my server's URL to indicate where to send the information:

image (33).png

 

Next, I will create a GA4 Event tag that will send consent at the appropriate time.

image (34).png

I called my event “axeptio_update”; this is how the event will be named on the server side when received, and I passed my axeptio_consent_state variable as an event parameter.

 

Then, I will trigger this tag on the “axeptio_update” trigger, which is an event sent by Axeptio whenever consent is read or modified:

image (35).png

Thus, consent will be transmitted to my server on every page load and/or consent modification.

 

2. Condition the tags in your server container

Now, on the server container side, we will need to receive the information sent from the client container.

For this, you will need to create a GA4 client in your server container if it hasn’t already been set up:

image (30).png

There is no special configuration required here.

 

Next, we will retrieve the “Axeptio Consent State” variable sent from the client.

To do this, I will create a user-defined variable of type “Event Data,” in which I will input the technical name of my variable, “axeptio_consent_state”:

image (31).png

 

Now that I have my variable containing the list of accepted cookies on the server side, I will be able to condition my tags to trigger based on the accepted cookies.

For example, I will create a GA4 “Page view” tag that I will trigger on the “axeptio_update” event.

To check consent at the time of triggering, I will add a condition on my variable to ensure it contains “google_analytics”:

image (32).png

 

If you don’t know where to find the technical name of your cookies (like “google_analytics” in this case), you can consult this section of the documentation:

How to retrieve the name of cookies

 

And that's it! My GA4 tag is now conditioned based on consent and can only be triggered if the visitor has accepted Google Analytics in the Axeptio banner.

You can do the same for your other cookies by replacing the condition on “google_analytics” with the name of the desired cookie.

Was this article helpful?

1 out of 1 found this helpful