I have implemented GA4 event into my website and another website on a different domain but both of them share the same measure ID. The second website is embedded in the first website using an iframe. Both of them send events but when it comes to the events send by the embedded page the source show as direct. Since the iframe get generated manually (iframe element is appended using JS), I have set the client_id and session_id manually as well,
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config','measure_id', { client_id : 'client_id from first website' : 'session_id' : 'session_id from first website' });
I have checked GA cookies on both sites and they both share the same cookie value. When I use Google analytic debugger I'm seeing this logs for event trigger from the second website(embedded one)
No session cookie found. Generating fresh session object.
Loaded existing client id: XXXXXXXXX
I'm seeing events from two different domains under a same user, but the source (First user source) comes as direct for second website.