Skip to main content

Shopify

The OptSens Embed & Sync app adds code to your storefront without theme edits: paste snippets into the head or body of every page, and sync consent decisions to Shopify's Customer Privacy API. The app is free and also works without an OptSens account, as a general code embed with a consent bridge your own banner can use.

Already have your OptSens embed code? Jump to Paste your embed code.

Install the app​

  1. In the Shopify App Store, search for OptSens Embed & Sync and open the listing.
  2. Click Install and approve the install for your store.

The app requests no store-data access scopes. After install, the app's admin screen shows three setup steps.

Use it with your own code​

The app ships two app embed blocks. Head code renders your snippet through Shopify's compliance head, in <head> ahead of other scripts. Body code renders before the closing </body> tag. Both render the pasted code exactly as you typed it: analytics, pixels, verification tags, or a consent banner.

If you built or integrated your own consent banner, it can push each visitor decision into Shopify's Customer Privacy API with one call:

window.EmbedSync.setConsent({
analytics: true,
marketing: false,
preferences: true,
saleOfData: false
});

Call it only after a real visitor choice. The bridge loads Shopify's consent-tracking feature for you and forwards the values. Code that may run before the bridge can push the same object onto window.EmbedSyncQueue instead.

Copy your embed code​

  1. Open your OptSens dashboard and add this store's domain.
  2. Copy your embed code from the Integration step of the guided onboarding, or later from the dashboard Integration page. It looks like this:
<script src="https://cdn.optsens.com/optsens.min.js/YOUR_DOMAIN_ID"></script>

Paste your embed code​

  1. In Shopify, open your theme editor and go to App embeds.
  2. Turn on Head code.
  3. Paste your embed code into the Head code field.
  4. Save the theme.

The Open theme app embeds button on the app's admin screen takes you straight to this panel. The banner needs only Head code; Body code stays off unless you use it for other snippets.

Configure Shopify Customer Privacy​

Two settings in your Shopify admin make OptSens the only banner on your storefront and let Shopify apply each visitor's consent choice.

  1. In your Shopify admin, open Settings and select Customer Privacy.
  2. In the Cookie banner section, choose More actions, then Remove cookie banner. OptSens becomes the only consent banner your visitors see.
  3. In the Regions section, choose Edit, then select where consent applies. Keep this aligned with your OptSens geo rules, or select all regions. Click Save.

Both settings are required for full functionality and legal compliance.

What the app does​

The Head code block renders your pasted code through Shopify's compliance head, the dedicated injection point for consent apps, which Shopify places in <head> ahead of other scripts. With your OptSens embed code pasted there, the banner loads exactly as on any website.

A bridge detects the OptSens banner and maps each consent decision onto Shopify's Customer Privacy API. Consent is forwarded only after a real visitor choice, never automatically, and the stored choice is replayed on return visits:

OptSens categoryCustomer Privacy API
Analyticsanalytics
Advertisingmarketing and sale_of_data
Functionalpreferences

Banner design, languages, geo rules and consent records are managed in your OptSens dashboard, not in the app.

After installing​

  1. Open your storefront in a private window. The banner shows on first visit.

  2. Check the consent sync: make a choice on the banner, then run this in the browser console:

    window.Shopify.customerPrivacy.currentVisitorConsent()

    The returned values mirror the choice: all yes after accepting everything, no on the optional categories after rejecting.

  3. Run the implementation check. During first-time setup it runs as the onboarding Verify step, and you can run it at any time from the dashboard Integration page.

  4. Work through Verify installation.

If the banner does not show, confirm the app embed is turned on, then see Install troubleshooting.