I have GA4 setup on a film blog containing a gallery of films. Each film item is a link to watch the film on an external domains e.g. Netflix/Prime/YouTube etc.
I am trying to track Outbound Links in GA and see a list of the most clicked films.
I have the site setup to measure outbound clicks automatically, but these don't give me the film titles of the items I'm trying to track.
The site is built on Notion and Super so I don't have access to the 'on page' HTML code so I can't add an onClick
event to each film item.
However, each film is an element with a class and the film name as an ID. For example:
class="notion-collection-card" id="shawshank-redemption"
class="notion-collection-card" id="the-matrix"
Question
Is there a way to add some JS to the <head>
or the <body>
to track each outbound link targeting them using the class
and then id
for each link as the Event Label so they appear as a list of film titles in analytics?
Reminder: I can't add onClick
events to the HTML directly. All I can do is add code to the <head>
, <footer>
or the top of the <body>
.
I solved this by following this guide (below): GA4 Enhanced Measurement doesn't track the link_text
link_id
or link_class
properties.
The guide explains how to setup a custom Outbound Click event in GTM and wire this up to capture these properties. Note: I had to move my setup to use a GTM container rather than the original gtag.js installation:
https://www.analyticsmania.com/post/missing-link-text-of-outbound-clicks-in-google-analytics-4/