scriptTagCreate
Requires access scope.
Theme app extensions
Your app might not pass App Store review if it uses script tags instead of theme app extensions. All new apps, and apps that integrate with Online Store 2.0 themes, should use theme app extensions, such as app blocks or app embed blocks. Script tags are an alternative you can use with only vintage themes. Learn more.
Script tag deprecation
Script tags will be sunset for the Order status page on August 28, 2025. Upgrade to Checkout Extensibility before this date. Shopify Scripts will continue to work alongside Checkout Extensibility until August 28, 2025.
Creates a new script tag.
Arguments
- Anchor to inputinput•Script
Tag requiredInput! The input fields for a script tag.
Anchor to ScriptTagCreatePayload returnsScriptTagCreatePayload returns
- Anchor to scriptTagscript•
Tag The script tag that was created.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
- Creates a new script tag
- scriptTagCreate reference
Examples
mutation ScriptTagCreate($input: ScriptTagInput!) {
scriptTagCreate(input: $input) {
scriptTag {
id
cache
createdAt
displayScope
src
updatedAt
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation ScriptTagCreate($input: ScriptTagInput!) { scriptTagCreate(input: $input) { scriptTag { id cache createdAt displayScope src updatedAt } userErrors { field message } } }",
"variables": {
"input": {
"src": "https://js.example.org/bar.js",
"displayScope": "ONLINE_STORE",
"cache": true
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation ScriptTagCreate($input: ScriptTagInput!) {
scriptTagCreate(input: $input) {
scriptTag {
id
cache
createdAt
displayScope
src
updatedAt
}
userErrors {
field
message
}
}
}`,
{
variables: {
"input": {
"src": "https://js.example.org/bar.js",
"displayScope": "ONLINE_STORE",
"cache": true
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation ScriptTagCreate($input: ScriptTagInput!) {
scriptTagCreate(input: $input) {
scriptTag {
id
cache
createdAt
displayScope
src
updatedAt
}
userErrors {
field
message
}
}
}`,
"variables": {
"input": {
"src": "https://js.example.org/bar.js",
"displayScope": "ONLINE_STORE",
"cache": true
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation ScriptTagCreate($input: ScriptTagInput!) {
scriptTagCreate(input: $input) {
scriptTag {
id
cache
createdAt
displayScope
src
updatedAt
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"input": {
"src": "https://js.example.org/bar.js",
"displayScope": "ONLINE_STORE",
"cache": true
}
}
response = client.query(query: query, variables: variables)