How to Configure Facebook pixel and conversion API for CCPA Compliance on Shopify

Summary

If you want to enable CCPA then the approach is:

  1. Create an opt-out CCPA form on your website following CCPA guidelines
  2. Create HTML tag within GTM to set a cookie if someone submits the CCPA form
  3. Add a 1st party cookie variable to grab the cookie
  4. Update email variables to pass an empty string if the user submitted the CCPA form
  5. Update all Facebook tags initializing the pixel to pass the processing option parameters
  6. Confirm your Conversion API setup supports CCPA

Step 1: Implement CCPA Form

You need a CCPA form on your website that users can submit their request of info not being used.

Here is [one example](. Note: there many variations of this implementation.

Step 2: Create HTML Tag in GTM

Set up an HTML tag in GTM to set a cookie if someone submits the CCPA form opting out.

Step 3: Add Variable to Grab Cookie

Create a 1st party cookie variable to grab the cookie set in the previous step.

Step 4: Update Email Variables

In this step, you’ll need to create another set of email variables that are the custom JS type that reference the dataLayer variable(s) used for email collection.

You’ll need to create email variables in GTM to be something like the following below to pass an empty string if they’ve opted out.

So – if user opted-out then don’t include email. Otherwise include it.

function(){ var optedIn = {{CCPA Cookie}}; if (optedIn){ return ''; } else { return {{dlv - Global - User Email}}; } }

These variables then need to be swapped out in the tag(s) that you were previously sending an email dataLayer variable to.

Step 5: Update Facebook pixel to pass the processing option parameters

In all Facebook tags that initialize the pixel (the Sitewide and Purchase tags if you are using our templates), add the following lines before the init call:

if ({{CCPA Cookie}}){ fbq('dataProcessingOptions', ['LDU'], 1, 1000); } else { fbq('dataProcessingOptions', []); }

Here is an example of it implemented:

Essentially we need to tell Facebook for the particular hit sent with their pixel if the data should be set up for limited use.

Step 6. Confirm your Conversion API setup supports CCPA

For the conversion API piece, you need to confirm two things:

  1. You are using our most up to date template for your server side GTM container (CCPA support was added 3/1/21). To confirm you have a template that supports CCPA, view the code of the "Facebook Server Side Events" template. You should see the following lines there:

  1. You are using "ccpaoptin" for your CCPA cookie in step two above.

That's it! With these two things in place, the templates will handle sending the data processing options based on the ccpa cookie.