ScriptTag

Version 2019-04

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-04/script_tags.json
Retrieves a list of all script tags.
limit

The number of results to return.

(default: 50, maximum: 250)
page
deprecated

The page of results to show.

(default: 1)
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-04/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": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    },
    {
      "id": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    }
  ]
}

Retrieve a list of all script tags with a particular URL

GET /admin/api/2019-04/script_tags.json?src=https://js-aplenty.com/foo.js
View Response
HTTP/1.1 200 OK
{
  "script_tags": [
    {
      "id": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    }
  ]
}

Retrieve a list of all script tags after the specified ID

GET /admin/api/2019-04/script_tags.json?since_id=421379493
View Response
HTTP/1.1 200 OK
{
  "script_tags": [
    {
      "id": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    }
  ]
}
GET /admin/api/2019-04/script_tags/count.json
Retrieves a count of all script tags
src

Count only script tags with a given URL.

Retrieve a count of all script tags for your shop

GET /admin/api/2019-04/script_tags/count.json
View Response
HTTP/1.1 200 OK
{
  "count": 2
}
GET /admin/api/2019-04/script_tags/#{script_tag_id}.json
Retrieves a single script tag
fields

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

Retrieve a single script tag by its ID

GET /admin/api/2019-04/script_tags/#{script_tag_id}.json
View Response
HTTP/1.1 200 OK
{
  "script_tag": {
    "id": 596726825,
    "src": "https://js-aplenty.com/foo.js",
    "event": "onload",
    "created_at": "2019-09-30T13:57:07-04:00",
    "updated_at": "2019-09-30T13:57:07-04:00",
    "display_scope": "all"
  }
}
POST /admin/api/2019-04/script_tags.json
Creates a new script tag

Create a new script tag

POST /admin/api/2019-04/script_tags.json
{
  "script_tag": {
    "event": "onload",
    "src": "https://djavaskripped.org/fancy.js"
  }
}
View Response
HTTP/1.1 201 Created
{
  "script_tag": {
    "id": 870402688,
    "src": "https://djavaskripped.org/fancy.js",
    "event": "onload",
    "created_at": "2019-09-30T13:59:09-04:00",
    "updated_at": "2019-09-30T13:59:09-04:00",
    "display_scope": "all"
  }
}

Creating a script tag without a src and event will return an error

POST /admin/api/2019-04/script_tags.json
{
  "script_tag": {
    "body": "foobar"
  }
}
View Response
HTTP/1.1 422 Unprocessable Entity
{
  "errors": {
    "src": [
      "can't be blank",
      "must be secure (HTTPS)"
    ],
    "event": [
      "can't be blank",
      "is invalid"
    ]
  }
}
PUT /admin/api/2019-04/script_tags/#{script_tag_id}.json
Updates a script tag

Update a script tag's URL

PUT /admin/api/2019-04/script_tags/#{script_tag_id}.json
{
  "script_tag": {
    "id": 596726825,
    "src": "https://somewhere-else.com/another.js"
  }
}
View Response
HTTP/1.1 200 OK
{
  "script_tag": {
    "id": 596726825,
    "src": "https://somewhere-else.com/another.js",
    "event": "onload",
    "created_at": "2019-09-30T13:57:07-04:00",
    "updated_at": "2019-09-30T13:59:10-04:00",
    "display_scope": "all"
  }
}
DELETE /admin/api/2019-04/script_tags/#{script_tag_id}.json
Deletes a script tag

Delete an existing script tag

DELETE /admin/api/2019-04/script_tags/#{script_tag_id}.json
View Response
HTTP/1.1 200 OK
{
}
Version 2019-07 (Latest)

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-07/script_tags.json
Retrieves a list of all script tags.
limit

The number of results to return.

(default: 50, maximum: 250)
page
deprecated

The page of results to show.

(default: 1)
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-07/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": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    },
    {
      "id": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    }
  ]
}

Retrieve a list of all script tags with a particular URL

GET /admin/api/2019-07/script_tags.json?src=https://js-aplenty.com/foo.js
View Response
HTTP/1.1 200 OK
{
  "script_tags": [
    {
      "id": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    }
  ]
}

Retrieve a list of all script tags after the specified ID

GET /admin/api/2019-07/script_tags.json?since_id=421379493
View Response
HTTP/1.1 200 OK
{
  "script_tags": [
    {
      "id": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    }
  ]
}
GET /admin/api/2019-07/script_tags/count.json
Retrieves a count of all script tags
src

Count only script tags with a given URL.

Retrieve a count of all script tags for your shop

GET /admin/api/2019-07/script_tags/count.json
View Response
HTTP/1.1 200 OK
{
  "count": 2
}
GET /admin/api/2019-07/script_tags/#{script_tag_id}.json
Retrieves a single script tag
fields

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

Retrieve a single script tag by its ID

GET /admin/api/2019-07/script_tags/#{script_tag_id}.json
View Response
HTTP/1.1 200 OK
{
  "script_tag": {
    "id": 596726825,
    "src": "https://js-aplenty.com/foo.js",
    "event": "onload",
    "created_at": "2019-09-30T13:57:07-04:00",
    "updated_at": "2019-09-30T13:57:07-04:00",
    "display_scope": "all"
  }
}
POST /admin/api/2019-07/script_tags.json
Creates a new script tag

Create a new script tag

POST /admin/api/2019-07/script_tags.json
{
  "script_tag": {
    "event": "onload",
    "src": "https://djavaskripped.org/fancy.js"
  }
}
View Response
HTTP/1.1 201 Created
{
  "script_tag": {
    "id": 870402688,
    "src": "https://djavaskripped.org/fancy.js",
    "event": "onload",
    "created_at": "2019-09-30T13:59:09-04:00",
    "updated_at": "2019-09-30T13:59:09-04:00",
    "display_scope": "all"
  }
}

Creating a script tag without a src and event will return an error

POST /admin/api/2019-07/script_tags.json
{
  "script_tag": {
    "body": "foobar"
  }
}
View Response
HTTP/1.1 422 Unprocessable Entity
{
  "errors": {
    "src": [
      "can't be blank",
      "must be secure (HTTPS)"
    ],
    "event": [
      "can't be blank",
      "is invalid"
    ]
  }
}
PUT /admin/api/2019-07/script_tags/#{script_tag_id}.json
Updates a script tag

Update a script tag's URL

PUT /admin/api/2019-07/script_tags/#{script_tag_id}.json
{
  "script_tag": {
    "id": 596726825,
    "src": "https://somewhere-else.com/another.js"
  }
}
View Response
HTTP/1.1 200 OK
{
  "script_tag": {
    "id": 596726825,
    "src": "https://somewhere-else.com/another.js",
    "event": "onload",
    "created_at": "2019-09-30T13:57:07-04:00",
    "updated_at": "2019-09-30T13:59:10-04:00",
    "display_scope": "all"
  }
}
DELETE /admin/api/2019-07/script_tags/#{script_tag_id}.json
Deletes a script tag

Delete an existing script tag

DELETE /admin/api/2019-07/script_tags/#{script_tag_id}.json
View Response
HTTP/1.1 200 OK
{
}
Version 2019-10 (Release candidate)

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. 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": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    },
    {
      "id": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-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": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    }
  ]
}

Retrieve a list of all script tags after the specified ID

GET /admin/api/2019-10/script_tags.json?since_id=421379493
View Response
HTTP/1.1 200 OK
{
  "script_tags": [
    {
      "id": 596726825,
      "src": "https://js-aplenty.com/foo.js",
      "event": "onload",
      "created_at": "2019-09-30T13:57:07-04:00",
      "updated_at": "2019-09-30T13:57:07-04:00",
      "display_scope": "all"
    }
  ]
}
GET /admin/api/2019-10/script_tags/count.json
Retrieves a count of all script tags
src

Count only script tags with a given URL.

Retrieve a count of all script tags for your shop

GET /admin/api/2019-10/script_tags/count.json
View Response
HTTP/1.1 200 OK
{
  "count": 2
}
GET /admin/api/2019-10/script_tags/#{script_tag_id}.json
Retrieves a single script tag
fields

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

Retrieve a single script tag by its ID

GET /admin/api/2019-10/script_tags/#{script_tag_id}.json
View Response
HTTP/1.1 200 OK
{
  "script_tag": {
    "id": 596726825,
    "src": "https://js-aplenty.com/foo.js",
    "event": "onload",
    "created_at": "2019-09-30T13:57:07-04:00",
    "updated_at": "2019-09-30T13:57:07-04:00",
    "display_scope": "all"
  }
}
POST /admin/api/2019-10/script_tags.json
Creates a new script tag

Create a new script tag

POST /admin/api/2019-10/script_tags.json
{
  "script_tag": {
    "event": "onload",
    "src": "https://djavaskripped.org/fancy.js"
  }
}
View Response
HTTP/1.1 201 Created
{
  "script_tag": {
    "id": 870402688,
    "src": "https://djavaskripped.org/fancy.js",
    "event": "onload",
    "created_at": "2019-09-30T13:59:09-04:00",
    "updated_at": "2019-09-30T13:59:09-04:00",
    "display_scope": "all"
  }
}

Creating a script tag without a src and event will return an error

POST /admin/api/2019-10/script_tags.json
{
  "script_tag": {
    "body": "foobar"
  }
}
View Response
HTTP/1.1 422 Unprocessable Entity
{
  "errors": {
    "src": [
      "can't be blank",
      "must be secure (HTTPS)"
    ],
    "event": [
      "can't be blank",
      "is invalid"
    ]
  }
}
PUT /admin/api/2019-10/script_tags/#{script_tag_id}.json
Updates a script tag

Update a script tag's URL

PUT /admin/api/2019-10/script_tags/#{script_tag_id}.json
{
  "script_tag": {
    "id": 596726825,
    "src": "https://somewhere-else.com/another.js"
  }
}
View Response
HTTP/1.1 200 OK
{
  "script_tag": {
    "id": 596726825,
    "src": "https://somewhere-else.com/another.js",
    "event": "onload",
    "created_at": "2019-09-30T13:57:07-04:00",
    "updated_at": "2019-09-30T13:59:10-04:00",
    "display_scope": "all"
  }
}
DELETE /admin/api/2019-10/script_tags/#{script_tag_id}.json
Deletes a script tag

Delete an existing script tag

DELETE /admin/api/2019-10/script_tags/#{script_tag_id}.json
View Response
HTTP/1.1 200 OK
{
}

Sign up for a Partner account to get started.

Sign up