Segment integrates with your consent management platform (CMP) to capture and enforce user consent preferences, routing events only to categories approved by the user.
You can read more about Segment Consent Management here.
Littledata uses Shopify's Customer Privacy API to control tracking based on customer consent.
Most Shopify cookie banners and some Consent Management Platforms (CMPs) support this Customer Privacy API.
For Consent Mode to work, you must have a cookie banner. You can set it up from your Shopify Admin by going to Settings -> Customer Privacy -> Cookie Banner, or use another banner app which is compliant with Shopify Customer Privacy API.
If the banner is created in-house, or a non-native Shopify solution is used, an implementation is required to update the customer privacy API with the given consent.
Shopify’s Customer Privacy API supports four consent types.
Segment requires every event from all of your sources to include the end user consent preferences, captured by your CMP or your application logic, in the form of the consent object
Segment Consent Management Parameter | Shopify Consent Type |
---|---|
Advertising = true/false | marketing = yes/no |
DataSharing = true/false | sale_of_data = yes/no |
Functional = true/false | preferences = yes/no |
Analytics = true/false | analytics = yes/no |
This consent object is sent with all events under the event context
object.
You must configure the Segment destinations to decide which ones are Advertising, Analytics, Functional or DataSharing.You can ignore step 2 - integrating your CMP - because Littledata has already done this for the** Shopify source.**
If you prefer not to collect non-consenting customer data in Segment, then you can exclude client-side events using source middleware for Segment’s AnalyticsJS library.
This example middleware script would drop events from being triggered if
context.consent.categoryPreferences.Advertising
is not true
.
window.analytics = window.analytics || [];
// Temporary implementation before the real script loads
if (!window.analytics.addSourceMiddleware) {
window.analytics.addSourceMiddleware = function () {
const e = Array.prototype.slice.call(arguments);
e.unshift('addSourceMiddleware');
window.analytics.push(e);
return window.analytics;
};
}
window.analytics.addSourceMiddleware(({ payload, next }) => {
if(payload?.obj?.context?.consent?.categoryPreferences?.Advertising) {
next(payload);
}
});