Tracking user consent is very important to keep in compliance with regulation such as GDPR and CCPA, and is good practice to keep your users happy. We offer extensive support for granular consent tracking.
Operations on user Profile data use the message type consent.
Operations
The operations parameter takes an array of operations. These can be of the following type:
set - add a consent for a type and value
unset - remove a consent for a type and value
Set
Simple Consent
You can set a basic user consent as in the example below, which indicates the user has consented to email at the address person@example.com.
{"type":"consent",// the operations"operations": [{"type":"set","key":"email","value":"person@example.com" }],// general message properties"writeKey":"<WRITE_KEY>","messageId":"213d7f53-ffac-4a58-a20b-5d609455d64c","timestamp":"2022-11-15T04:31:44Z","userId":"5.wBOQ7hKNVgIUcJn5IbX.1670273082","sessionId":"28eef5c8-1098-4f76-abe9-58a921cabfaf","pageId":"eca34e0f-4802-4fa4-8db1-11c727839dbd""context": {"page": {"url":"https://www.weather-station.com/","path":"/","referrer":"","title":"Weather Station - Get Weather" }, }}"operations": [ {"type":"set","key":"email","value":"person@example.com","purpose": [ {"type":"marketing","topics": ["Men's Clothing","Men's Accessories" ] } ] } ] }]
Adding a Purpose
A user may only give consent for a specific purpose ie "marketing". You can add these details to a set operation by adding a purpose attribute. This is an array of objects, with the type of the purpose supplied.
This example adds consent for both "marketing" and "transactional" emails:
{"type":"consent",// the operations"operations": [{"type":"set","key":"email","value":"person@example.com","purpose": [ {"type":"marketing" }, {"type":"transactional" } ] }],// general message properties"writeKey":"<WRITE_KEY>","messageId":"213d7f53-ffac-4a58-a20b-5d609455d64c","timestamp":"2022-11-15T04:31:44Z","userId":"5.wBOQ7hKNVgIUcJn5IbX.1670273082","sessionId":"28eef5c8-1098-4f76-abe9-58a921cabfaf","pageId":"eca34e0f-4802-4fa4-8db1-11c727839dbd""context": {"page": {"url":"https://www.weather-station.com/","path":"/","referrer":"","title":"Weather Station - Get Weather" }, }}
Adding Topics
A user may only want to be contacted for a specific purpose about certain topics. For example a user may only want to get "marketing" material from you about "Men's Shoes" and "Bridal wear".
This example adds topics to the "marketing" purpose:
{"type":"consent",// the operations"operations": [{"type":"set","key":"email","value":"person@example.com","purpose": [ {"type":"marketing","topics": ["Men's Shoes","Bridal wear"] }, {"type":"transactional" } ] }],// general message properties"writeKey":"<WRITE_KEY>","messageId":"213d7f53-ffac-4a58-a20b-5d609455d64c","timestamp":"2022-11-15T04:31:44Z","userId":"5.wBOQ7hKNVgIUcJn5IbX.1670273082","sessionId":"28eef5c8-1098-4f76-abe9-58a921cabfaf","pageId":"eca34e0f-4802-4fa4-8db1-11c727839dbd""context": {"page": {"url":"https://www.weather-station.com/","path":"/","referrer":"","title":"Weather Station - Get Weather" }, }}
If topics are supplied they will override any existing topics for a given purpose. You cannot use this to remove all topics by sending an empty array ie topics: [] though.
Unset
This example removes the email consent for the email address person@example.com. Unset does not take any purpose or topics and these can only be changed using the set type.
{"type":"consent",// the operations"operations": [{"type":"unset","key":"email","value":"person@example.com" }],// general message properties"writeKey":"<WRITE_KEY>","messageId":"213d7f53-ffac-4a58-a20b-5d609455d64c","timestamp":"2022-11-15T04:31:44Z","userId":"5.wBOQ7hKNVgIUcJn5IbX.1670273082","sessionId":"28eef5c8-1098-4f76-abe9-58a921cabfaf","pageId":"eca34e0f-4802-4fa4-8db1-11c727839dbd""context": {"page": {"url":"https://www.weather-station.com/","path":"/","referrer":"","title":"Weather Station - Get Weather" }, }}