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

  • 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!