CodeUp Page Targeting

Page targeting allows you to control exactly which pages of your Shopify store will load your custom code. This feature is useful when you need different code on different page types, or when you want to limit where certain scripts run.

How Page Targeting Works

By default, when no pages are selected, your code will load on all pages of your store. When you select specific pages, your code will only load on those selected page types.

Available Page Types

CodeUp supports targeting the following Shopify page templates:

Page TypeDescriptionExample URLs
HomeYour store’s homepageyourstore.com/
CollectionCollection/category pagesyourstore.com/collections/summer-sale
ProductIndividual product pagesyourstore.com/products/blue-shirt
CartThe shopping cart pageyourstore.com/cart
BlogBlog listing pagesyourstore.com/blogs/news
ArticleIndividual blog post pagesyourstore.com/blogs/news/my-article
SearchSearch results pageyourstore.com/search?q=shirt
PagesStatic/custom pagesyourstore.com/pages/about-us
404Page not found error pageyourstore.com/invalid-page

Configuring Page Targeting

Step-by-Step Instructions

  1. Navigate to the Setup page in the CodeUp app
  2. Add your code to the Header code and/or Body code text areas
  3. Scroll down to the Select pages to apply section
  4. Check the boxes for the pages where you want your code to appear
  5. Click Save to apply your changes
Page Selection Checkboxes

Default Behavior

When no pages are selected:

  • Code loads on ALL pages of your store
  • This is the default behavior
  • Best for tracking codes that should run everywhere (like Google Analytics)

When specific pages are selected:

  • Code loads ONLY on selected page types
  • Other pages will not include your code
  • Best for page-specific functionality or targeted scripts

Common Use Cases

Track All Pages (Analytics)

For analytics and tracking pixels that need to run on every page:

  • Selection: Leave all checkboxes unchecked
  • Result: Code loads on all pages

Suitable for:

  • Google Analytics
  • Facebook Pixel
  • TikTok Pixel
  • General site-wide tracking

Product Page Only

For code that should only run on product pages:

  • Selection: Check only “Product”
  • Result: Code loads only on product pages

Suitable for:

  • Product-specific tracking events
  • Product page customizations
  • Review widgets that display on products
  • Size guides or fit finders

Check only the “Product” checkbox to limit code to product pages only.

Cart and Checkout Related

For code that should run when customers are in the buying process:

  • Selection: Check “Cart” and optionally “Product”
  • Result: Code loads on cart page (and product pages if selected)

Suitable for:

  • Cart abandonment tracking
  • Upsell/cross-sell widgets
  • Shipping calculator scripts

Content Pages Only

For code that should only run on blog and static pages:

  • Selection: Check “Blog”, “Article”, and “Pages”
  • Result: Code loads only on content pages

Suitable for:

  • Reading time calculators
  • Social sharing widgets for articles
  • Content-specific styling

Homepage Only

For code that should only appear on your homepage:

  • Selection: Check only “Home”
  • Result: Code loads only on the homepage

Suitable for:

  • Homepage-specific banners or popups
  • Homepage sliders or carousels
  • Seasonal/promotional scripts

Viewing Your Page Targeting Configuration

Your current page targeting settings are displayed on the Dashboard in the Code setup overview section:

  • Page templates row shows which pages have your code applied
  • If specific pages are selected, you will see: “Applied to: Home, Product, Cart…”
  • If all pages are targeted, you will see: “All pages”
Code Setup Overview showing Page Templates

Tips and Best Practices

Performance Optimization

  • Be specific: Only load code on pages where it is needed
  • Reduce overhead: Don’t load heavy scripts on pages that don’t need them
  • Consider user experience: Page-specific code loads faster than bloated global scripts

Multiple Code Snippets

If you need different code on different pages, you have two options:

  1. Use conditional logic in your code: Add JavaScript that checks the current page before executing
  2. Prioritize: Add the most important/universal code and use page targeting for specific needs

Testing Your Configuration

After configuring page targeting:

  1. Save your changes
  2. Visit different page types on your store
  3. Check the page source (Ctrl+U or Cmd+U) to verify your code appears only where expected
  4. Use browser developer tools to confirm scripts are loading correctly

Troubleshooting Page Targeting

Code appears on all pages despite selecting specific pages

  • Make sure you clicked Save after making changes
  • Clear your browser cache and check again
  • Verify the theme extension is enabled (see Theme Extension Management)

Code doesn’t appear on selected pages

  • Confirm the theme extension (Head code or Body code) is enabled
  • Check if your code has any errors that prevent it from rendering
  • Verify you have code entered in the appropriate text area

Need more granular control?

If you need to target more specific pages (like a single product or collection), you can add conditional logic directly in your code:

<script>
  // Only run on a specific product
  if (window.location.pathname.includes('/products/specific-product-handle')) {
    // Your code here
  }
</script>

Related Guides

Last updated on February 16, 2026

Was this article helpful?

PREVIOUS

Getting Started with CodeUp

NEXT

CodeUp FAQ

Powered by Support Genix