Add ga track to the order status page to send event events

Highlighted
New Member
3 0 0

I want to add GA tracking on the order status page to send event events. After various attempts, I found that the normal js in the Additional scripts can be executed, but the ga-related operations are all invalid. I am again in the Additional Google Analytics JavaScript
The checkout is added, but the code is not displayed at all on the order status page.

 

My Additional scripts code is as follows:

 

<script type="text/javascript">
    alert('1');  //can be executed
    ga('send','event','test2','test2','test2',1);  //can not be executed
    ga('send', 'pageview', {
        'dimension3': 'test'
    });  //can not be executed
</script>

 

So what should I do?

0 Likes
Excursionist
20 0 5

Hi @Appler,

 

try to include GA right before your event scripts. (admin/settings/checkout -> additional scripts)
Don´t forget to replace the GA-Id with your personal one.

<!-- Google Analytics -->
<script>
(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','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto');

ga('send','event','test2','test2','test2',1);  //can not be executed

ga('send', 'pageview', {
        'dimension3': 'test'
}); 
</script> <!-- End Google Analytics -->


Hope that helps :-)

Was this answer helpful?
Leave a thumbs up, so others might find it faster.

Would you like to learn more about Shopify Development?
You might like my Youtube Channel
0 Likes