Learn business growth with Google Analytics 4 Forums Google Analytics 4 Effectively tracking cross-domain user journeys in GA4 based on domain A referrals

  • Effectively tracking cross-domain user journeys in GA4 based on domain A referrals

    Posted by Charlotte on 13 March 2023 at 7:57 pm

    Hey, I need a little help with something – I’m trying to figure out how to track traffic between two different sites in GA4 – one that’s ours (let’s call it domainA) and the other that’s run by a partner of ours (we’ll call it domainB). What I need to do is track visitors going from domainA to domainB, including what they end up doing on domainB. But the catch is – I only want to follow the users who initially kicked off their browsing on domainA. If they started on domainB, I’d rather not have them in my data. So, unless the user’s journey begins at domainA and takes them to domainB, I’d like their session to remain untracked.

    So I’ve got data streams cooking for both domainA and domainB, and GA4 is on the ball about collecting data between these two. However, if someone starts on domainB without a prior visit to domainA, GA4 is still keeping tabs on them – not really what I’m after.

    In case you’re wondering, I’ve set the data stream for domainB to take domainA into account in the configure domain settings within Data Streams.

    ✅ This is what I’m after
    Diagram explaining flow that we want

    Fancy any idea how I might go about this? Am I on the right track using data streams? To keep it simple, I’m hoping for a minimal setup for domainB. You know, something like a bite-sized snippet in <head> tag to get the tracking running.

    Amelia replied 11 months, 2 weeks ago 3 Members · 2 Replies
  • 2 Replies
  • Caleb

    Member
    25 April 2023 at 1:17 pm

    No problem, I got you! Here’s a way you could solve this using a conditional loading of the GA4 library:

    If I have this right, you only want your GA4 snippet to run on domainB if visitors initially landed on domainA, correct? No sweat! Assuming that you have your analytics setup without GTM, here are a couple of pointers you can follow:

    1. Since your domains are different TLDs and you have cross-domain linking enabled between domainA and domainB, when the page loads on domainB, you could check if the URL carries the ?_ga parameter with your measurement id, or if a special cookie flag is set.

    2. Now if either of those are true, you can then recreate the special cookie flag and load the library as usual. If neither is true, then don’t do anything – essentially leaving those alone who jumped straight into domainB.

    If your domains aren’t TLDs and you don’t need cross-domain tracking, you could use the document.referrer to check who landed on domainB from domainA. This way, you can handle the scenario you want without adding too much load to domainB. Neat, right?

    Basically, you’re on the right track with your data streams, but you just need a little tweak. Give it a try, fingers crossed it helps!

  • Amelia

    Member
    8 July 2023 at 5:03 pm

    You could consider using a referral exclusion in GA4 for domain B, which should exclude traffic that starts on domain B. Then, you can experiment with UTM parameters to determine if a user is coming from domain A. Use these parameters in your links going from domain A to domain B, then set a conditional load of the GA4 tag on domain B based on the existence of a UTM parameter. This way, you’ll only track visitors who came from domain A to domain B, not those who started on domain B.

Log in to reply.