Skip to content
English - United States
  • There are no suggestions because the search field is empty.

Adding Page-Specific Code Using the Global PageName Function

You can write code that will only execute on specific pages of your storefront (for example, product pages only, category pages only, etc.). As always, please archive your theme before making any changes.

After you've written your page-specific code, paste it into the script provided below. Replace with the page you want your code to run on. Then, put the full script (with your custom code) into your template_xx.html file, where "xx" is the name or ID number of your theme, at Design > File Editor > Shortcuts.

<script>
var Page = PageName() || 'default.asp';
if( Page === 'one-page-checkout') {
console.log("THIS RUNS ON THE CHECKOUT PAGE")
} else if (Page === 'productdetails.asp') {
console.log("THIS RUNS ON THE PRODUCT DETAILS PAGE")
} else {
console.log("THIS WILL RUN ON OTHERS PAGES AND OUTPUT THE PAGENAME:"+Page)
}
</script>