Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
Hello,
I am building an affiliate referal type of application. I am using a script tag to check for a parameter that a customer will arrive on the homepage using for example. mystore.com?aff=test
The value of aff is then stored as a cookie on the page and set to expire in 30 days time. The only problem is ideally I want this cookie to be passed to the checkout so that it is sent with the order webhook.
I was following this discussion up until it mentions saving the value as a cart attribute. I can't find anything online about how to create a cart attribute from the homepage. https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/way-to-access-a-1st-party-cookie-set-o...
I have looked at using the ?ref= parameter instead but the cookie used for it only lasts 8 hours and I'm not sure If i can change that.
Hope someone can help!
Regards, Jack
For those that stumble across this.
I used document.cookie standard javascript to create the cookie with a custom name.
I then used this:
jQuery.post('/cart/update.js', { attributes: {trackingcode: cookieval}});
to post the tracking code to the checkout as an attribute. Took me a while to find that line of code but hope it helps someone!
I have the same problem that is trying to solved. Any luck with this?
User | RANK |
---|---|
5 | |
4 | |
4 | |
4 | |
3 |