Using Segment Consent Management with Shopify
What is Segment Consent Management?
Segment Consent Management accepts signals from your Consent Management Platform (CMP) to capture and enforce user consent preferences, routing events only to destinations approved by the user.
Segment requires every event from your sources to include end-user consent preferences, captured by your CMP or application logic, in the form of the consent object.
How does Littledata work with Segment Consent Management?
Littledata uses Shopify's Customer Privacy API to track 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.
If your store uses another CMP, your CMP will need to update the customer privacy API with the given consent, or use a plugin for OneTrust.
Mapping of Shopify consent types to Segment
Shopify’s Customer Privacy API supports four consent types, and Littledata maps these onto Segment Consent.
Segment Consent Type | Shopify Consent Type |
---|---|
Advertising | marketing |
DataSharing | sale_of_data |
Functional | preferences |
Analytics | analytics |
For all consent types a true
value equals a 'yes' value on Shopify.
Segment Consent value | Shopify Consent value |
---|---|
true | yes |
false | no |
This consent
object is sent with all events within the event context
object.
Configuring Segment destinations to use consent
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.
Blocking all client-side events based on consent
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);
}
});