In this post, I will discuss how analytics data of the redirected visitors can be optimized in the case of automatic redirection.

First of all, let’s understand what is the root cause of not getting accurate results in the analytics data.

Our app redirects the visitor after they come on the initial website and then the redirection takes place.

To trigger a redirect, our app uses a JS script. Similarly, Google and Shopify analytics has their scripts.

So, when a visitor visits the website the analytics script is triggered before the redirection due to which visitors data is shown for the initial website visit in its analytics section from where he/she is already redirected.

Due to this, the redirected visitors analytics data has some discrepancies.

How to overcome the discrepancies?

We have proposed a workaround to tackle this situation by adding our app’s speedup snippet in the theme file of the store.

By default, Shopify loads the app js after finishing the page load. As a result, it takes a few seconds before the redirect takes place.

If we add the snippet before the variable {{ content_for_header }} which includes scripts for Google Analytics, Shopify analytics then the visitors will be redirected before the analytics script gets triggered which will yield accurate data in the analytics as well as significantly faster redirection.

Here are the steps to add the app’s speedup snippet :

1. Go to the theme.liquid in your Shopify store.
2. Copy the below script
3. Paste the script just below the opening tag of the <head> section of the theme.liquid file.

 assign geospeedup = shop.metafields.geoip_country_r.geoip_country_r_scriptpath
 if(geospeedup != "disabled")
 echo shop.metafields.geoip_country_r.geoip_country_r_scriptpath | script_tag

Please note that the above solution does not guarantee 100 percent results because our app’s and the analytics scripts may run parallel. You can contact us on our email if any problem persists.

If you face any difficulty please contact us at