Tracking user interactions across multiple domains is essential for understanding how users are moving through your online presence and where they are dropping off. Google Analytics 4 (GA4) offers a powerful way to do this, but setting up cross-domain tracking manually can be tricky, especially if you're not a web developer or analytics expert.
We'll walk you through the step-by-step process of setting up GA4 cross-domain tracking manually. We'll break down the technical aspects and provide clear instructions on what to do. Come on let’s dive right into it - here are the steps:
The manual setup is done by using the get and set commands of the gtag.js API to store IDs across domains. If you want to learn more, you can check out this documentation.
gtag('get', 'TAG_ID', 'client_id', (client_id) => {
// Store the client ID in a variable.
});
gtag('get', 'TAG_ID', 'session_id', (session_id) => {
// Store the session ID in a variable.
});
<a href="https://example.com/?clientId=XXXXX&sessionId=YYYYY">example.com</a>
gtag('config','TAG_ID', {
'client_id': getClientIdFromUrl(),
'session_id': getSessionIdFromUrl()
});
Once you've completed the steps above, be sure to test your setup to ensure that cross-domain tracking is working properly. To do this, check the URL of the destination domain to make sure the _gl parameter is present.
We believe you can gain more knowledge, and here are some resources (Blog Posts) to help you continue learning: