Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to read cookies of parent window from an embedded app?

How to read cookies of parent window from an embedded app?

JoesIdeas
Shopify Partner
2427 225 651

I'm trying to read cookie of a user when they install the app, for example:

 

1. Person lands on a specific website page that cookies them

2. They install the app from the Shopify app store

3. Certain actions happen based on if they have the cookie or not

 

Seems cookies aren't accessible, wondering if anyone knows how or has an idea for an alternate flow.


The only idea I have is to find a way to get users to go to the website again to do the cookie check, but that's essentially an extra wasted action.

• Creator of Order Automator [auto tag, fulfill, connect FBA, daily jobs]
• Co-Creator of Product Automator [suite of features for products / collections]
• Shopify developer for 10+ years, store owner for 7 years
• Blog: Shopify Tips, Guides, and Automation Tools
Replies 4 (4)

SBD_
Shopify Staff
1831 273 419

Hey @JoesIdeas 

 

I don't think there's a workaround (unless maybe you have their store url during the first step?)

Checking with some other folks - will report back!

Scott | Developer Advocate @ Shopify 

JoesIdeas
Shopify Partner
2427 225 651

Thanks Scott for checking on this.

 

We don't have the store url from the first step, the first step links to the app listing page, attaching cookies, but there are no input forms (trying to make it easiest for the user, direct them to the solution and not make them submit forms).

 

 

• Creator of Order Automator [auto tag, fulfill, connect FBA, daily jobs]
• Co-Creator of Product Automator [suite of features for products / collections]
• Shopify developer for 10+ years, store owner for 7 years
• Blog: Shopify Tips, Guides, and Automation Tools
SBD_
Shopify Staff
1831 273 419

Sorry to say they don't have a great solution either:

> yeah that's a tricky one - browsers really don't want you to do that. Maybe setting SameSite=none (MDN) in the cookie might work. That being said, safari is really strict about these (and I think chrome got stricter too recently), so you have to go through ITP to be able to read the cookies from the iframe, which requires a user action (like a click or something)

Scott | Developer Advocate @ Shopify 

JoesIdeas
Shopify Partner
2427 225 651

I wonder if there's a way to transfer the user's Shopify url to Google Analytics when they install the app from the Shopify app store page?

 

Then maybe we could use a url parameter for the referring page, and match that up with the user installing at that same time.

 

Then we could run a separate script that checks Google Analytics via API and compares the url parameter and installed store url with the user, then performs the action (tags them based on the source they came from, to cater specific features, etc).

• Creator of Order Automator [auto tag, fulfill, connect FBA, daily jobs]
• Co-Creator of Product Automator [suite of features for products / collections]
• Shopify developer for 10+ years, store owner for 7 years
• Blog: Shopify Tips, Guides, and Automation Tools