# webPixelCreate - admin-graphql - MUTATION Version: 2025-01 ## Description Creates a new web pixel settings. ### Access Scopes `write_pixels` access scope. Also: The app requires read_customer_events access scope and user access permission. ## Arguments * [webPixel](/docs/api/admin-graphql/2025-01/input-objects/WebPixelInput): WebPixelInput! - The web pixel settings in JSON format. ## Returns * [userErrors](/docs/api/admin-graphql/2025-01/objects/ErrorsWebPixelUserError): ErrorsWebPixelUserError! The list of errors that occurred from executing the mutation. * [webPixel](/docs/api/admin-graphql/2025-01/objects/WebPixel): WebPixel The created web pixel settings. ## Examples ### Create a web pixel Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation webPixelCreate($webPixel: WebPixelInput!) { webPixelCreate(webPixel: $webPixel) { userErrors { field message code } webPixel { id settings } } }\",\n \"variables\": {\n \"webPixel\": {\n \"settings\": {\n \"trackingId\": \"GA-TRACKING-ID-123\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation webPixelCreate($webPixel: WebPixelInput!) {\n webPixelCreate(webPixel: $webPixel) {\n userErrors {\n field\n message\n code\n }\n webPixel {\n id\n settings\n }\n }\n }`,\n \"variables\": {\n \"webPixel\": {\n \"settings\": {\n \"trackingId\": \"GA-TRACKING-ID-123\"\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation webPixelCreate($webPixel: WebPixelInput!) {\n webPixelCreate(webPixel: $webPixel) {\n userErrors {\n field\n message\n code\n }\n webPixel {\n id\n settings\n }\n }\n }\nQUERY\n\nvariables = {\n \"webPixel\": {\n \"settings\": {\n \"trackingId\": \"GA-TRACKING-ID-123\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation webPixelCreate($webPixel: WebPixelInput!) {\n webPixelCreate(webPixel: $webPixel) {\n userErrors {\n field\n message\n code\n }\n webPixel {\n id\n settings\n }\n }\n }`,\n {\n variables: {\n \"webPixel\": {\n \"settings\": {\n \"trackingId\": \"GA-TRACKING-ID-123\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation webPixelCreate($webPixel: WebPixelInput!) {\n webPixelCreate(webPixel: $webPixel) {\n userErrors {\n field\n message\n code\n }\n webPixel {\n id\n settings\n }\n }\n}" #### Graphql Input { "webPixel": { "settings": { "trackingId": "GA-TRACKING-ID-123" } } } #### Graphql Response { "data": { "webPixelCreate": { "userErrors": [], "webPixel": { "id": "gid://shopify/WebPixel/937414752", "settings": "{\"trackingId\":\"GA-TRACKING-ID-123\"}" } } } } ### Creating a web pixel with invalid settings returns an error Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation webPixelCreate($webPixel: WebPixelInput!) { webPixelCreate(webPixel: $webPixel) { userErrors { field message code } webPixel { id settings } } }\",\n \"variables\": {\n \"webPixel\": {\n \"settings\": {}\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation webPixelCreate($webPixel: WebPixelInput!) {\n webPixelCreate(webPixel: $webPixel) {\n userErrors {\n field\n message\n code\n }\n webPixel {\n id\n settings\n }\n }\n }`,\n \"variables\": {\n \"webPixel\": {\n \"settings\": {}\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation webPixelCreate($webPixel: WebPixelInput!) {\n webPixelCreate(webPixel: $webPixel) {\n userErrors {\n field\n message\n code\n }\n webPixel {\n id\n settings\n }\n }\n }\nQUERY\n\nvariables = {\n \"webPixel\": {\n \"settings\": {\n\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation webPixelCreate($webPixel: WebPixelInput!) {\n webPixelCreate(webPixel: $webPixel) {\n userErrors {\n field\n message\n code\n }\n webPixel {\n id\n settings\n }\n }\n }`,\n {\n variables: {\n \"webPixel\": {\n \"settings\": {}\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation webPixelCreate($webPixel: WebPixelInput!) {\n webPixelCreate(webPixel: $webPixel) {\n userErrors {\n field\n message\n code\n }\n webPixel {\n id\n settings\n }\n }\n}" #### Graphql Input { "webPixel": { "settings": {} } } #### Graphql Response { "data": { "webPixelCreate": { "userErrors": [ { "field": [ "webPixel" ], "message": "Missing keys: trackingId", "code": "INVALID_SETTINGS" } ], "webPixel": null } } }