Skip to main content

Pass the consent into its GTM Server-side container

Written by Alexandre Dias Da Silva

If you have set up server-side tracking via GTM, you are probably wondering how to make these reports compliant with Axeptio.

In this documentation, we will see how to transmit the 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

First, we will need a tag in the server container, whose job will be to send the consent information to the server container, each time the consent is modified.

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

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

We will then create a tag that will be responsible for transmitting it.

Here, I am using GA4 to send information to the server container, but there are other alternatives if you wish.

In my GA4 configuration tag, I added a "server_container_url" parameter, with the URL of my server, to indicate where to send the information:

image (27).png

Next, I will create a GA4 Event tag, which will be responsible for sending the consent at the right time.

image (28).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.

Finally, I will trigger this tag on the "axeptio_update" trigger, which is an event sent by Axeptio each time the consent is read or modified:

image (29).png

Thus, the consent will be transmitted to my server each time the page loads and/or the consent is modified.

2. Condition tags in your server container

On the server container side now, we will need to receive the information sent by the client container.

For this, you will need to create a GA4 client in your server container if not already done

image (30).png

There is no special configuration to do here.

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

For this, I will create a user-defined variable, of type "Event Data", in which I will put the technical name of my variable, which is "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 so that they are triggered based on the accepted cookies.

I will for example create a GA4 "Page view" tag that I will trigger on the "axeptio_update" event.

To verify consent at the time of triggering, I will add a condition on my variable, to verify that it indeed contains "google_analytics":

image (32).png

If you do not know where to find the technical name of your cookies (such as "google_analytics" here), you can consult this section of documentation:

And there you have it, my GA4 tag is conditioned to 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.

Did this answer your question?