Set settings.fields.accountID value from shopify.extension.toml

Solved

Set settings.fields.accountID value from shopify.extension.toml

ricardov
Shopify Partner
2 0 0

I am following this guide: https://shopify.dev/docs/apps/marketing/pixels/getting-started#step-5-create-a-web-pixel-setting-for...

 

I am currently on the step 5, and I need to run the GraphQL query (I don't have any problems with that) with the `accountID`, but on the `shopify.extension.toml` file there's only the definition of the field and cannot set the value.

 

My question is, where do I set this value, and if this is auto-generated, where can I retrieve it from?

Accepted Solution (1)

Liam
Shopify Staff
2873 312 821

This is an accepted solution.

Hi Ricardov,

 

The accountID value is not auto-generated - it's a field that you define in your shopify.extension.toml file. It is used to store the account ID your web pixel for a specific shop. 

 

When you run the webPixelCreate mutation in step 5, you set the accountID value in the settings parameter of the mutation. This can be any value that you need for your specific application.

 

Here is the example mutation from the guide:

mutation {
  webPixelCreate(webPixel: { settings: "{\"accountID\":\"234\"}" }) {
    userErrors {
      code
      field
      message
    }
    webPixel {
      settings
      id
    }
  }
}

In this example, the accountID is set to 234. You can replace 234 with the account ID that you want to use for your web pixel.

 

After the mutation is successful, the accountID value is stored in settings of the web pixel for the shop. You can then retrieve this value by querying the webPixel object for the shop.

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Reply 1 (1)

Liam
Shopify Staff
2873 312 821

This is an accepted solution.

Hi Ricardov,

 

The accountID value is not auto-generated - it's a field that you define in your shopify.extension.toml file. It is used to store the account ID your web pixel for a specific shop. 

 

When you run the webPixelCreate mutation in step 5, you set the accountID value in the settings parameter of the mutation. This can be any value that you need for your specific application.

 

Here is the example mutation from the guide:

mutation {
  webPixelCreate(webPixel: { settings: "{\"accountID\":\"234\"}" }) {
    userErrors {
      code
      field
      message
    }
    webPixel {
      settings
      id
    }
  }
}

In this example, the accountID is set to 234. You can replace 234 with the account ID that you want to use for your web pixel.

 

After the mutation is successful, the accountID value is stored in settings of the web pixel for the shop. You can then retrieve this value by querying the webPixel object for the shop.

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog