Run scripts or show content only on the first visit to the order status page

Caution

This is an advanced tutorial and is not supported by Shopify. Knowledge of web design languages such as HTML, CSS, Javascript and Liquid is required. We suggest hiring a Shopify Expert if you are not comfortable proceeding with the following tutorial.

The order status page lets your customers check on the status of their shipments. It is common to include sales conversion tracking scripts on this page because it is the final page of checkout. This means that a customer who returns to check on their order status might count as a second sale in your analytics.

To prevent your analytics from counting the same customers more than once, you can add the first_time_accessed property around some or all of your Additional scripts. With the first_time_accessed code in place, Shopify will run your Additional scripts only the first time your customers see their order status page.

Using first_time_accessed

You will probably want to use the first_time_accessed property if you use conversion tracking on your order status page, but you can also add it around any code you want to run only once on the order status page.

  1. From your Shopify admin, click Settings, and then click Checkout.

  2. In the Order processing section, find the Additional scripts text box:

    Additional content 1

  3. Copy and paste this if/else statement to the top of your Additional scripts:

    
    {% if first_time_accessed %}
      <!-- Conversion scripts you want to run only once -->
    {% else %}
      <!-- Scripts you want to run on every visit -->
    {% endif %}
    
    
  4. Cut and paste your code snippets into the space above or below the {% else %} tag.

    The code snippets that you include above the {% else %} tag will run only once and the code that you include below it will run every time the order status page is visited.

  5. Click Save.

Want to discuss this page?

Visit the Shopify Community