Run scripts only on first visit

It is common to include scripts that track sales conversions on the order status page because it is the final page of checkout. However, customers who return to check their order status might count as a second sale in your analytics.

To prevent your analytics from counting customers more than once, you can add the first_time_accessed property around some or all of your additional scripts. To do this, use a Liquid if statement, and place any scripts that you only want to run once between {% if first_time_accessed %} and {% endif %} tags.

Steps:

  1. Under Order processing, go to the Additional scripts text box.

  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 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.

Ready to start selling with Shopify?

Try it free