OnetrustActiveGroups - Using the Data Layer Object

« Go Back
OnetrustActiveGroups - Using the Data Layer Object

A data layer is a JavaScript object that is used to pass information from your website to whatever tag manager you utilize. You can then use the information found in the data layer to populate variables and create triggers to fire or not fire scripts the drop cookies based on user consent. The OneTrust Cookie Consent data layer object to use to do this is OnetrustActiveGroups.

Rather than referencing variables, transaction information, page categories, and other important signals scattered throughout your page, some tag managers are designed to easily reference information that is included in the data layer. How you will implement this will vary from tag manager to tag manager.

OneTrust Cookie Consent populates a data layer object OnetrustActiveGroups with the cookie categories that the user has consented to.

Once the banner script is implemented on the page, you will be able to call OnetrustActiveGroups from the console using developer tools in a browser and see which cookie category IDs are currently active.


For example, a website using a script with an opt-in consent model configured, on initial page load only the Strictly Necessary category ID would be within OnetrustActiveGroups.


If the user accepted all categories, all category IDs would populate in OnetrustActiveGroups, and with the appropriate triggers set up cookies associated with all the category IDs would be dropped on the browser.


Perhaps the user only accepted the Functional cookie category. The data layer object would contain the category IDs associated with the Strictly Necessary and Functional cookie categories.


The data layer will be an essential tool in testing the Cookie Consent implementation. You can check which category IDs the user is opted into and ensure the correct tags are firing or not firing based on the consent.


You can find your cookie category IDs under Categorizations > Categories.

If you use custom category IDs, these IDs will populate in the data layer object.

Only the categories that are associated with the script will populate in the data layer object. So if you do not have cookies categorized in a particular category for a domain, that category will not show up in the preference center or in the data layer object.

Bundle Group IDs (An ID associated with a header group configured on your template), if used, will also populate in the data layer object. You should not use Bundle Group IDs to trigger scripts or tags to fire or not fire, only use cookie category IDs.


Powered by