Google Analytics has long been a go-to tool for tracking and analyzing website data, providing valuable insights into user behavior and performance metrics. For Magento users, integrating GA4 into their server-side implementation can unlock a wealth of data and enable more precise tracking and reporting.
In this article, we will explore the benefits of server-side Google Analytics 4 for Magento and provide a step-by-step guide on setting up the Magento plugin, empowering you to harness the full potential of the e-commerce data.
Here we would like to outline the benefits of implementing server-side GA4 for your Magento Store:
3. The key feature of server-side tagging is setting first-party cookies. You need to use a custom tagging server URL to enable this feature. Custom tagging server URL or custom domain should share the same domain as your website. For example, if your website domain is example.com, then the tagging server URL should look like ss.example.com.
If you want to add a custom domain, open the sGTM container on stape, scroll to the domains section, type the domain name, and click Add domain. Once done, you will see DNS records that you should add.
Below is an example of DNS setup for CloudFlare.
4. Go back to the Google Tag Manager Server container -> Choose your server container -> Admin -> container settings -> paste tagging server URL.
Updating the Web GTM script on your website is highly recommended if you use a custom domain. This tweak will make gtm.js load from your domain. To do so, replace the default domain googletagmanager.com with the custom domain you set up in the previous step.
5. Inside the Web container, create a new tag of the tag Type Google Tag. Add your Google Tag ID.
In the section Configuration settings add the following parameters:
Add trigger to GA4 tag. Normally it should trigger on all page views.
You can also create a Google tag: Configuration settings variable that will predefine Google Tag settings if you need to use multiple Google Tags on your website and do not want to add settings for each of the tags manually.
These parameters can be, for example, a setting that defines whether you want to send a page view event every time a Google Tag triggers, set UTM parameters, client ID, etc. There is a list of standard Google Tags configuration parameters.
6. To set up the GA4 event, go to the tags section and create a new tag with the tag type Google Analytics: GA4 Event. Add your GA4 ID and the event name; there is a list of standard event names.
You can create a Google Tag: Event Settings variable that will help to share event parameters across several GA4 event tags or Google Tags. It can be, for example, user or product properties, and there is also a list of standard parameters for event settings.
7. Open Google Tag Manager Server container -> go to Tags and set up GA4 tag. Remember that GA4 automatically sends not only pageview but some other events. Inside Event Name choose variable {{Event Name}}. -> add trigger Client Name equals GA4.
8. Open the Server container preview mode and check that you see GA4 requests. Publish updated inside server and web Google Tag Manager containers.
Implementing server-side Google Analytics 4 for Magento offers significant advantages and unlocks a new level of data-driven insights for e-commerce businesses. By shifting the tracking process to the server, businesses can achieve enhanced data accuracy, consistent tracking across devices and platforms, improved data privacy and compliance, customization options, and better scalability and performance.
By following the step-by-step guide provided in this article, using Magento you can seamlessly set up server-side GA4 and harness the full potential of the e-commerce data.
We've got you covered! Click Get help, fill-up the form, and we will send you a quote.