Learn business growth with Google Analytics 4 Forums Google Analytics 4 Analyzing Event Source on an Embedded Page with GA4

  • Analyzing Event Source on an Embedded Page with GA4

    Posted by Li on 24 January 2023 at 5:46 am

    “How can I correct my GA4 setup on two websites, one embedded with an iframe in the other, so that the source doesn’t display as ‘direct’ for the embedded site? I manually set the client_id and session_id since the iframe generates manually too. I noticed that both sites share the same GA cookie value. The Google Analytics Debugger shows no session cookie found and an already existing client id for the embedded site.”

    John replied 10 months, 4 weeks ago 3 Members · 2 Replies
  • 2 Replies
  • Ashton

    Member
    28 May 2023 at 1:55 am

    To correct your GA4 setup across two websites, you would need to accurately setup cross-domain tracking. Since you’re dealing with two sites (one of which is embedded via an iFrame), proper attribution is necessary to avoid ‘direct’ sources. Consider creating separate GA cookies for each site, which will contribute to more accurate tracking. You may have to modify the way you generate client_id and session_id. The issue you’re having with both sites sharing the same GA cookie value suggests that the sites are not being seen as distinct by Google Analytics, hence causing attribution issues. If the debugger shows an already existing client id for the embedded site but not a session cookie, it signifies a possible error in the way these elements are being generated or tracked. You might need to bring in a developer with expertise in Google Analytics tracking to fix these issues.

  • John

    Member
    30 June 2023 at 6:40 pm

    To correct your GA4 setup on two websites to ensure that the source doesn’t display as ‘direct’ for the embedded site, it may be beneficial to use Google Tag Manager (GTM). This can help to manage the data layer and control which data is sent and when. Additionally, it is important to ensure that each website is set up as a separate data stream in the property settings on GA4.

    In GA4, all website interactions are considered as events and can be customized, hence you can manually set the session_id and client_id on page load through GTM, especially for your embedded iframe site. Your services can use GTM‘s JavaScript APIs to retrieve the GA client ID and set for every hit sent from the iframe.

    Despite sharing the same GA cookie value, be aware that cross-domain tracking may cause issues, such as sessions being split across domains. To solve this, cross-domain measurement may be necessary to correctly attribute sessions. In your case, there is a missing linker parameter when the user navigates into the iframe (or from the iframe), which results in the inability to correctly attribute sessions.

    Remember to double-check your GA4 debugging output to ensure no other discrepancies are causing issues with the data. Finally, test everything in a non-production environment and gradually roll out changes, monitoring effects on your traffic and other metrics to avoid larger issues.

Log in to reply.