Can I set up outlink click tracking for GA4 on my Shopify store?

NOMVDIC
Visitor
3 0 2

Hi, 

I use the outlink app on my shopify store and had Google Analytics tracking set up. I'm working on migrating over to GA4, but wasn't sure how to set up outlink click tracking for GA4? Thanks in advance!

Reply 1 (1)

NomtechSolution
Astronaut
1245 113 147

Find the GA4 tracking code: Look for the existing GA4 tracking code in your theme.liquid file. It should look something like this:

 

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR-GA4-TRACKING-ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'YOUR-GA4-TRACKING-ID');
</script>

 

  1. Make a note of the "YOUR-GA4-TRACKING-ID" value, as you'll need it for the next step.

  2. Add the outlink click tracking code: Insert the following code snippet just before the </script> tag in the GA4 tracking code:

 

gtag('event', 'click', {
  'event_category': 'Outbound Link',
  'event_label': 'YOUR-OUTLINK-LABEL'
});