All things Shopify and commerce
Hey everyone,
It's been a few days now I have a roadblock, so I would love to pick your brains.
I have an app that's I'm trying to build and I need to install & connect a Webpixel at the app installation.
So far I managed to create the Webpixel app extension and I can see the pixel in the backend as not connected.
I managed to connect the Webpixel by manually using GraphiQL.
But I'd like to be able to do this automatically at the app installation.
I can't seem to find a way to make this GraphQL query work in Remix and I don't know where it should be located in the project.
Hi,
Hope following will help
- Go to setup part of your Remix app.
- Use GraphQL API to send a request.
Here is the code example
import { shopifyApi, LATEST_API_VERSION } from "@shopify/shopify-api";
export async function setupWebPixel(shop, accessToken) {
const client = new shopifyApi.clients.Graphql({
shop,
accessToken,
apiVersion: LATEST_API_VERSION,
});
const mutation = `
mutation ConnectWebPixel($webPixelId: ID!) {
webPixelUpdate(id: $webPixelId, input: { connected: true }) {
webPixel {
id
connected
}
userErrors {
field
message
}
}
}
`;
const response = await client.query({
data: {
query: mutation,
variables: { webPixelId: "YOUR_PIXEL_ID" },
},
});
console.log("WebPixel Connection Response:", response);
}
- Call function when the app installs.
Thanks so much for taking the time to answer. What do you call the setup part of remix? What file is that?
Sorry, I'm new to Remix.
I can't find one example online of this webPixelCreate that works.
Thanks in advance
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025