We're software that helps growing brands & retailers grow and scale. Sync, sell and ship your products and inventory on online marketplaces and storefronts faster, easier and more accurately.

Learn more now

Google Universal Analytics Migration to Google Analytics 4

Starting July 1, 2023, standard Universal Analytics properties will stop processing new data. This guide covers the migration from Google Universal Analytics to Google Analytics 4 in your SureDone storefront template and settings. If you have launched your storefront on or after this date, it is very likely your website template already has the below configuration in place.


1. Set or update your Google Analytics account ID

Go to Settings > Storefront > Website Tracking. Note: this section will only show up if you have a custom website domain set already - Google Analytics 4 accounts start with "G-" vs Universal Analytics started with "UA-".



2. Update your active storefront template

Below is the code that needs to be updated in the html-header.htm file of the active template:

{% if sd_option('site_tracking') == 'on' and sd_option('site_tracking_google_account') is not empty  %}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ sd_siteinfo('google_analytics') }}"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', '{{ sd_siteinfo('google_analytics') }}');
  {{ sd_ga_tracking_code }}
</script>
{% endif %}

The Universal Analytics code that is to be replace is shown below:

{% if sd_option('site_tracking') == 'on' and sd_option('site_tracking_google_account') is not empty  %}
{% set gaDomain = is_ga_suredone ? 'suredone.com' : 'auto' %}
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-{{ sd_siteinfo('google_analytics') }}', '{{ gaDomain }}')
ga('set', 'forceSSL', true);
ga('require', 'displayfeatures');
ga('require', 'ec');{{ sd_ga_tracking_code }}
ga('send', 'pageview');
</script>
{% endif %}

Also, you may remove the code from footer.htm shown below:

{% if sd_option('site_tracking') == 'on' and sd_option('site_tracking_google_account') is not empty %}
<script type="text/javascript">
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>
{% endif %}

3. View storefront page source so confirm the new code is loaded correctly

4. Check your Realtime Reports to confirm everything is working

Confirm everything is working at https://analytics.google.com/analytics/web/