Cookie consent and custom pixels

Topic summary

Main issue: How to load custom marketing pixels only after users consent via Shopify’s cookie consent banner.

Key needs:

  • A method/variable to detect a visitor’s consent state specifically for marketing cookies.
  • Ability to conditionally activate a pixel injected in the body tag.
  • Guidance on doing this with Hydrogen (Shopify’s headless framework) where multiple custom pixels/cookies are used.

Context:

  • “Custom pixel” refers to marketing tracking code that should respect cookie preferences.
  • “Hydrogen” is Shopify’s framework for building custom storefronts.

Status: No solution or best-practice shared yet; participants are asking whether a consent signal/API exists and if anyone has implemented this successfully.

Open questions: Which Shopify-provided variables/events expose consent, and how to integrate them reliably in Hydrogen and theme contexts.

Summarized with AI on December 17. AI used: gpt-5.

Hi!

I’m using Shopify’s cookie consent banner. I must add a custom pixel to body-tag which is used for marketing. Is there a way to activate pixel only when user has given consent to use marketing cookies? Is there some variables that show the user consent?

Thanks in advance.

2 Likes

I am also very interested in this. We would love to use Shopify’s native Cookie Consent Banner with our Hydrogen implementation, but we have many custom pixels/cookies that we would need to incorporate. Has anyone figured out a way to do this?