Run scripts only on first visit

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 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 use it with any code that you want to run only once on the order status page. To do this, you can use a Liquid if statement, and place any scripts that you only want to run once between {% if first_time_accessed %} and {% endif %} tags.

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

    Additional content 1

  2. Paste the following code into the Additional scripts box:

    {% if first_time_accessed %}
      <!-- Conversion scripts you want to run only once -->
    {% endif %}
    
      <!-- Scripts you want to run on every visit -->
    
  3. If you want a script to run only on the first time that the order status page is accessed, then paste it between the {% if first_time_accessed %} and {% endif %} tags. If you want a script to run every time the order status page is accessed, then paste it below the {% endif %} tag.

  4. Click Save.

Want to discuss this page?

Visit the Shopify Community

Ready to start selling online with Shopify?

Try it free