ScriptTag

Version 2019-10

The ScriptTag resource represents remote JavaScript code that is loaded into the pages of a shop's storefront or the order status page of checkout. This lets you add functionality to those pages without using theme templates.

Script tags are scoped to the app that created them. When an app is uninstalled from a shop, all of the script tags that it created are automatically removed along with it.

What you can do with ScriptTag

The Shopify API lets you do the following with the ScriptTag resource. More detailed versions of these general actions may be available:

ScriptTag properties

created_at
read-only
"created_at": "2012-08-24T14:01:47-04:00"

The date and time (ISO 8601) when the script tag was created.

event
required
"event": "onload"

The DOM event that triggers the loading of the script. Valid values: onload.

id
read-only
"id": 596726825

The ID for the script tag.

src
required
"src": "https://js-aplenty.com/foo.js"

The URL of the remote script.

display_scope
"display_scope": "online_store"

The page or pages on the online store where the script should be included. Valid values:

  • online_store: Include the script only on the web storefront.
  • order_status: Include the script only on the order status page.
  • all: Include the script on both the web storefront and the order status page.

updated_at
read-only
"updated_at": "2012-08-24T14:01:47-04:00"

The date and time (ISO 8601) when the script tag was last updated.

Endpoints

GET /admin/api/2019-10/script_tags.json
Retrieves a list of all script tags. Note: As of version 2019-10, this endpoint implements pagination by using links that are provided in the response header. Sending the page parameter will return an error. To learn more, see Making requests to paginated REST Admin API endpoints.
limit

The number of results to return.

(default: 50, maximum: 250)
since_id

Restrict results to after the specified ID.

created_at_min

Show script tags created after this date. (format: 2014-04-25T16:15:47-04:00)

created_at_max

Show script tags created before this date. (format: 2014-04-25T16:15:47-04:00)

updated_at_min

Show script tags last updated after this date. (format: 2014-04-25T16:15:47-04:00)

updated_at_max

Show script tags last updated before this date. (format: 2014-04-25T16:15:47-04:00)

src

Show script tags with this URL.

fields

A comma-separated list of fields to include in the response.

Retrieve a list of all script tags

GET /admin/api/2019-10/script_tags.json
View Response
HTTP/1.1 200 OK
{
  "script_tags": [
    {
      "id": 421379493,
      "src": "https://js-aplenty.com/bar.js",
      "event": "onload",
      "created_at": "2021-07-01T14:25:22-04:00",
      "updated_at": "2021-07-01T14:25:22-04:00",
      "display_scope": "all"
    },
    {
      "id": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2021-07-01T14:25:22-04:00",
      "updated_at": "2021-07-01T14:25:22-04:00",
      "display_scope": "all"
    }
  ]
}

Retrieve a list of all script tags with a particular URL

GET /admin/api/2019-10/script_tags.json?src=https://js-aplenty.com/foo.js
View Response
HTTP/1.1 200 OK
{
  "script_tags": [
    {
      "id":