Shopify

Our Shopify cookie banner implementation uses the Customer Privacy APIarrow-up-right and connects it to our consent function.

Let's go over how we are doing this and what to expect.

Our consent handler is only triggered once EdgeTag is fully initialized, for which we are listening for edgetag-initialized event that EdgeTag SDK fires once we get data back from the edge.

Next, we will determine whether the user is new or existing. For new users, we will read the current settings in the customer privacy section and send them to our consent function. For existing users, we already have their consent stored in memory.

For all users, we will listen for the consent change event, which will be triggered by Shopify via the visitorConsentCollected eventarrow-up-right. Once we receive a signal from Shopify that the customer changed their consent, we will process the data and send it to our consent function.

Let's examine how we process settings before sending them to the consent function. In our processing, we are looking for two different scenarios. Is the user in a region where the sale of data is applied or not? To check that we are calling saleOfDataRegion functionarrow-up-right. If the user is in that region, we will use saleOfData setting when setting consent for marketing and analytics.

If the user is not in that region, we will map analyticsAllowed to our analytics consent and marketingAllowed to our marketing consent.

You can also see our pseudo-code below to explain what we are doing:

let marketing = false
let analytics = false

if (window.Shopify.customerPrivacy.saleOfDataRegion()) {
 marketing = window.Shopify.customerPrivacy.saleOfDataAllowed()
 analytics = window.Shopify.customerPrivacy.saleOfDataAllowed()
} else {
  marketing = window.Shopify.customerPrivacy.marketingAllowed()
  analytics = window.Shopify.customerPrivacy.analyticsProcessingAllowed()
}

edgetag(
  'consent', 
  null, 
  { all: false, necessary: true, advertising: marketing, analytics: analytics }
)

If our logic doesn't match your consent banner, you can always select CUSTOM in our Cookie banner selection and use our consent function to send us consent.

Last updated

Was this helpful?