How to run scripts only on the first visit

run

scripts,

the

first

visit

From the order status page, your analytics will count the sale regardless of the customers just check on their shipments. This might cause wrong analytics. Hence, to prevent them from counting inaccurate, you can learn how to run scripts only on the first visit so that your additional scripts is run only the first time your customers view their order status page.

How to run scripts only on the first visit

Step 1: Go to Checkout

Log in your Shopify account firstly. Click on Setting which is at the bottom of the admin page. Then, choose Checkout.

Step 2: Go to the Additional scripts

Scroll down to view the Order processing section. You will see four options in it. Make sure to find out Additional scripts which is the last.

Step 3: Run the script on order status page

Take a look at the following code. The first thing you need to do is copying the code. Afterward, paste it into the Additional scripts text box. This code is to run the script on the order status page.

{% if first_time_accessed %}
<!-- Conversion scripts you want to run only once -->
{% endif %}
<!-- Scripts you want to run on every visit -->

Step 4: Run scripts only on the first visit

In this step, take notice of the range which you’ve pasted the code. The sentence I’ve marked with a red rectangle is the script. If you put it between the {% if first_time_accessed %} and {% endif %} tags, it will be run only on the first time the customers access the order status page.

Otherwise, if you put the script below the {% endif %} tag, then, the script will be run every time the order status page is opened.

Step 5: Click Save

Finally, make sure you’ve done successfully by clicking Save button.

To run scripts only on the first visit on Iphone

Step 1: Click Setting

From your Shopify app, click Store. Then, choose Setting.

Step 2: Go to the Checkout section

Make sure that you select Checkout in the Store setting field.

Step 3: Find the Additional scripts

In this step, find the Order processing section. Then, you will see four options appeared. Find out the Additional scripts and click on the text box.

Step 4: Paste the following code

Make sure to copy the below code firstly. Then, you need to paste it in the Additional scripts text box. This action is to run a script when the order status page is accessed.

{% if first_time_accessed %}
<!-- Conversion scripts you want to run only once -->
{% endif %}
<!-- Scripts you want to run on every visit -->

Step 5: Decide how many time the script will be shown

If you want the script to be shown only on the first time the customers access the order status page, paste it between the {% if first_time_accessed %} and {% endif %} tags.

Or else, a script will be shown every time the order status page is accessed by pasting it below the {% endif %} tag.

Step 1: Click Setting

Step 2: Go to the Checkout section

Step 3: Find the Additional scripts

In this step, look at the Order processing field. Four different options are displayed. Find out the Additional scripts and click on the text box.

Step 4: Paste the code

You’d better copy the following code in advance. In the Additional scripts text box, paste the code you’ve copied. This code is to run the script on the order status page.

{% if first_time_accessed %}
<!-- Conversion scripts you want to run only once -->
{% endif %}
<!-- Scripts you want to run on every visit -->

Step 5: Decide where to paste the script

In this step, take notice of the range which you’ve pasted the code. The sentence I’ve marked with a red rectangle is the script. If you put it between the {% if first_time_accessed %} and {% endif %} tags, it will be run only on the first time the customers access the order status page.

Otherwise, if you put the script below the {% endif %} tag, then, the script will be run every time the order status page is opened.

Step 6: Save

Select Save to make sure that you’ve followed this guide successfully.

Summary

Above are some simple steps you can take to run scripts only on the first visit. After following this, hope you have the accurate analytics. Visit more guides we wrote for you to generate your Shopify account more effectively.