Re: How can I retrieve the Shop_id from a web_pixel event?

How can I retrieve the Shop_id from a web_pixel event?

Sherki
Shopify Partner
12 0 3

Hello,
I have implemented a shopify web_pixel and am listening to checkout_completed events.
When receiving the event, is there any way to get shop information, like shop_id or Shopify.shop value or ".myshopify" domain name

 

I am subscribing to event as follows

analytics.subscribe('checkout_completed', async (event)

I Checked the event object, as well as object like 'browser'.
 
I am able to get the same via the order object sent in orders webhook. Looking for similar information via web-pixel object

Any information will be highly helpful




Replies 7 (7)

ketsueki
Shopify Partner
1 0 0

Did you find a workaround?

ebbo-dev
Shopify Partner
1 0 0

Create a field in your extension.toml, something like:

 

 

[settings.fields.shopID]
name = "Shop ID"
description = "Shop ID"
type = "single_line_text_field"

 

 

Then when you call the webPixelCreate set the settings variable similar to the following:

 

 

{
  "webPixel": {
    "settings": "{\"shopID\":\"mystore.myshopify.com\"}"
  }
}

 


After that the shopID variable will be available inside the pixels settings param.

 

 

register(async ({ analytics, browser, settings, init }) => {
  // Bootstrap and insert pixel script tag here
  const shopID = settings.shopID;
}

 

remy727
Shopify Partner
44 2 26

This returns .myshopify domain

init?.data?.shop?.myshopifyDomain

 

Looking for a Shopify App developer? Please contact me at remy.wang727@gmail.com
andrija_obradov
Shopify Partner
10 0 1

Hey yes it did, thanks for help! 

mike_signorella
Shopify Partner
8 0 4

In my custom web pixel the init.data.shop object is completely missing. Is there a specific set of circumstances where the shop field is not available? I'm listening to the checkout_completed event.

Screen Shot 2024-08-28 at 2.08.12 PM.png

remy727
Shopify Partner
44 2 26

I think you checked event.data, not init.data.

 

remy727_0-1724869725175.png

 

Looking for a Shopify App developer? Please contact me at remy.wang727@gmail.com
mike_signorella
Shopify Partner
8 0 4

I'm an idiot, thank you 😅