I’m trying to add a cookie to root domain using the Shopify Web Pixel API (@shopify/web-pixels-extension) but if my utm link is /products or /anything except root, it adds the cookie to that path. This makes the cookie inaccessible for any other page and breaks my core functionality.
I tried this:
await api.browser.cookie.set('myapp_ref', affiliateId, {
path: '/',
});
I then visited a page with “/products/name?myapp_ref=Beckett” but the cookie path was still /products.
I also tried adding domain to the cookie initialization but that also didn’t work:
await api.browser.cookie.set('myapp_ref', affiliateId, {
path: '/',
domain: hostname
});
This leads me to suspect that the pixel api uses a different syntax to specify cookie paths (if it allows that at all).
My hail mary approach was to try checking for a myapp_ref cookie with the /products path (from a different path) to just get the cookie (not ideal but whatever) but that also didn’t work.
Would really appreciate any input!!