SOLVED

Re: Integrating OneTrust "Do Not Sell My Personal Information" Cookie with Marketo

Go to solution
bart_borosky
Level 1

Integrating OneTrust "Do Not Sell My Personal Information" Cookie with Marketo

Our team has successfully implemented the OneTrust cookie/consent manager on our website, including the "Do Not Sell My Personal Information" cookie.

 

Now, we're aiming to integrate this "Do Not Sell My Personal Information" OneTrust cookie with a field in Marketo, to avoid adding any "Do not sell" people to certain campaigns.

 

I'm reaching out for technical insights or tips from someone has has managed to integrate the "Do Not Sell My Personal Information" cookie with a Marketo record and field, and potentially other consent segments from OneTrust to Marketo.

 

Thanks in advance for any help on this.
Bart

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Integrating OneTrust "Do Not Sell My Personal Information" Cookie with Marketo

The OneTrust cookie is called OptanonConsent. It has a predictable, part-standard encoding that’s easy to decode.

 

Here’s an example value:

 

isGpcEnabled=0&datestamp=Sat+Jan+13+2024+20%3A24%3A04+GMT-0500+(Eastern+Standard+Time)&version=202308.1.0&browserGpcFlag=0&isIABGlobal=false&hosts=&consentId=5c7582be-2173-4c6d-b027-5471792054b3&interactionCount=1&landingPath=NotLandingPage&groups=1%3A1%2C3%3A1%2CSPD_BG%3A1%2C2%3A1%2C4%3A1

 

 

Say you have that cookie value in a variable optanonCookie .

 

First, you URL-decode just as you would a query string.

 

let optanonStoredData = new URLSearchParams(optanonCookie);

 

 

Now, one query param groups contains a comma-delimited list of colon-delimited key:value pairs:

 

1:1,3:1,SPD_BG:1,2:1,4:1

 

 

Parse that param into a standard JS Map object like this:

 

let optanonGroups = new Map(optanonStoredData.get("groups").split(",").map((entry) => entry.split(":")));

 

 

The Map keys are the OneTrust group names (which can be numeric strings or alpha strings). Each group is either string "0" for disabled or string "1" for enabled.

 

Get a single group like so:

 

let optanonSPDGroup = optanonGroups.get("SPD_BG"); // returns "1" for the cookie above

 

 

You can read the group names out of the popup HTML. See where the group name SPD_BG corresponds to the “Sale of Personal Data” toggle?

SanfordWhiteman_0-1705196801036.png

SanfordWhiteman_1-1705197601033.png

 

Just run the code above in a Forms 2.0 onSubmit and you can write OneTrust group settings to individual hidden fields.

 

P.S. To avoid having to include your own document.cookie parser code (to get the optanonCookie out of the whole cookie string to start with) create a Marketo field like Raw Optanon Consent Cookie. Add that new field as Hidden, filling from cookie OptanonConsent. Then Marketo will put that cookie value in a field, so you can read it inside onSubmit like

let optanonCookie = form.getValues().rawOptanonConsentCookie;

 

@Jo_Pitts1 

View solution in original post

3 REPLIES 3
Chris_Willis1
Level 8 - Champion

Re: Integrating OneTrust "Do Not Sell My Personal Information" Cookie with Marketo

Hi Bart - this is a great item to add to the Ideas thread.  Looking forward to seeing it.  

SanfordWhiteman
Level 10 - Community Moderator

Re: Integrating OneTrust "Do Not Sell My Personal Information" Cookie with Marketo

The OneTrust cookie is called OptanonConsent. It has a predictable, part-standard encoding that’s easy to decode.

 

Here’s an example value:

 

isGpcEnabled=0&datestamp=Sat+Jan+13+2024+20%3A24%3A04+GMT-0500+(Eastern+Standard+Time)&version=202308.1.0&browserGpcFlag=0&isIABGlobal=false&hosts=&consentId=5c7582be-2173-4c6d-b027-5471792054b3&interactionCount=1&landingPath=NotLandingPage&groups=1%3A1%2C3%3A1%2CSPD_BG%3A1%2C2%3A1%2C4%3A1

 

 

Say you have that cookie value in a variable optanonCookie .

 

First, you URL-decode just as you would a query string.

 

let optanonStoredData = new URLSearchParams(optanonCookie);

 

 

Now, one query param groups contains a comma-delimited list of colon-delimited key:value pairs:

 

1:1,3:1,SPD_BG:1,2:1,4:1

 

 

Parse that param into a standard JS Map object like this:

 

let optanonGroups = new Map(optanonStoredData.get("groups").split(",").map((entry) => entry.split(":")));

 

 

The Map keys are the OneTrust group names (which can be numeric strings or alpha strings). Each group is either string "0" for disabled or string "1" for enabled.

 

Get a single group like so:

 

let optanonSPDGroup = optanonGroups.get("SPD_BG"); // returns "1" for the cookie above

 

 

You can read the group names out of the popup HTML. See where the group name SPD_BG corresponds to the “Sale of Personal Data” toggle?

SanfordWhiteman_0-1705196801036.png

SanfordWhiteman_1-1705197601033.png

 

Just run the code above in a Forms 2.0 onSubmit and you can write OneTrust group settings to individual hidden fields.

 

P.S. To avoid having to include your own document.cookie parser code (to get the optanonCookie out of the whole cookie string to start with) create a Marketo field like Raw Optanon Consent Cookie. Add that new field as Hidden, filling from cookie OptanonConsent. Then Marketo will put that cookie value in a field, so you can read it inside onSubmit like

let optanonCookie = form.getValues().rawOptanonConsentCookie;

 

@Jo_Pitts1 

bart_borosky
Level 1

Re: Integrating OneTrust "Do Not Sell My Personal Information" Cookie with Marketo

thank you so much! above and beyond @SanfordWhiteman