Data Layer
Unified Consent emits a data layer that contains a subject's privacy choices. The data layer is an item in the array window.dataLayer, with the "event": "consent-status".
Example response from window.dataLayer
{
"event": "consent-status",
"type": "explicit",
"gpc": false,
"accepted": string[] // Array of accepted privacy protocol IDs
"rejected": string[] // Array of rejected privacy protocol IDs
"undetermined": string[] // Array of undetermined privacy protocol IDs
}
Key | Value | Description |
event | consent-status | |
type | implicit, explicit | If the subject make a passive choice, such as setting their GPC signal, then 'implicit'. If the subject enters a choice directly thru an API, Embedded page or modal, then 'explicit'. |
gpc | true, false | True if GPC signal is enabled, else false. |
accepted | Array of accepted privacy protocol IDs | Each privacy protocol will have a unique Target ID. Any privacy protocols that have received opt-in consent from a user will be present in the array. |
rejected | Array of rejected privacy protocol IDs | Each privacy protocol will have a unique Target ID. Any privacy protocols that have received opt-out consent from a user will be present in the array. |
undetermined | Array of undetermined privacy protocol IDs | Each privacy protocol will have a unique Target ID. Any privacy protocols that a subject has not made any choice will be present in the array. |
Configuring Google Tag Manager
In this section, we are going to walk through configuring your Google Tag Manager to conditionally fire tags based on a subject's consent or preference selection.
Prerequisites
In order to follow this documentation, we assume you have:
- A Google Tag Manager account created and embedded on your website.
- Completed initial setup of a Unified Consent Preference Hub and have Embedded it into your website.
To configure Google Tag Manager (GTM) to listen to events pushed into the Data Layer follow the below steps.
Create Variables
In Unified Consent, each preference hub or consent prompt will connect to one or more privacy protocols defined in that configuration. Every Privacy Protocol has a corresponding Target ID. Inside Google Tag Manager, we’ll need to create variables with default consent statuses that match the Target ID of the Privacy Protocols.
- Navigate to "Variables" in the side menu of the Google Tag Manager.
- Click on “New” under the user defined variables section.
- Select "Data Layer Variable" as the new variable type.
- In the top left, name the variable "[Consent Target Name] Variable".
- Name the variable something that will be easy to remember and associate with the applicable Privacy Protocol in Osano.
- Under "Data Layer Variable Name", insert the privacy protocol's “Target ID”.
- This is a unique value that is static and will not be affected by any name changes to the Target Name or Privacy Protocol settings.
- The value must match exactly the “Target ID” configured in the product for this consent for the variable to communicate with Unified Consent's SDK.
- Check the "Set Default Value" checkbox and set the default value to false.
- Save your new variable.
- Repeat for all privacy protocols you would like to link to Google Tag Manager.
Example of completed Variable
Add Triggers
There are several ways on how to implement triggers in a Google Tag Manager. Osano recommends the following option:
- Navigate to "Triggers" in the side menu of Google Tag Manager.
- Click “New”.
- Select "Custom Event" as the trigger type.
- In the top left, name the trigger "[Consent Target Name] Trigger".
- Name the trigger something that will be easy to remember and associate with the applicable Privacy Protocol in Osano.
- Check the "Use regex matching" checkbox next to the "Event Name" input field
- Under "Event Name", insert "(consent-status.*)".
- Check the "Some Custom Events" checkbox.
- In the drop-down menus, set the following condition: “[Consent Target Name] Variable” contains true.
- Save "[Consent Target Name] Trigger".
Example of a completed Trigger
Next Steps
From here you will want to add the Triggers as a step to any tags in Google Tag Manager. This should be the trigger of any tag in GTM that needs to be conditionally fired on this consent. Repeat this for each privacy protocol configured in your consent center that is relevant to your tag management implementation.