Uliana Lesiv
AuthorAfter Universal Analytics sunset, Google Analytics 4 (GA4) became one of the most popular analytics tools. If you are going to use or already use server-side GA4 and want to connect it to your BigCommerce website, you are in the right place.
In this article, we will consider how to set up server-side BigCommerce GA4 integration.
1.1 Select your GTM account → Click Admin → Click + next to the Container name.

1.2 Add Container Name → Under Target platform, choose Server. Click Create.

1.3 Choose Manually provision tagging server. Copy your container config. We will need it in the following steps.

2.1 Go to Stape and create an account or log in. You can try our service for free and explore the benefits of Stape hosting for the GTM server.

2.2 Press the button Create container in the top right corner.
2.3 Enter your container details:
Then click Create Container.

2.4 Choose a plan for your container. You can start with a Free plan. Click Continue with a Free plan.

You will see the status of your container, container config, and plan name. It takes several minutes to deploy a server container. Please reload the page to update the status. If the setup was done correctly, you should see the status Running.

The critical feature of server-side tagging is setting first-party cookies, which requires a server-side setup. You need to use a custom tagging server URL or domain to enable this feature. The custom tagging server URL or custom domain should share the same domain as your website.
Due to cookie restrictions, configuring custom domains for sGTM has become more complex. ITP affects user tracking in Safari and Firefox.
To improve your tracking, you need to set up a custom domain. It will help you prolong your cookie lifetime in all browsers.
Let’s discuss ways to configure a custom domain for your sGTM tagging server URL.
There are three ways to set up a custom domain:
However, the “Same origin” method is technically advanced. You'll require a CDN or a load balancer to configure a same origin domain.

If you can't configure the same origin domain, we have solutions for prolonging cookie lifetime in Safari: Own CDN and Cookie Keeper.
By default, when you add your custom subdomain to your Stape container, it will be verified by the CNAME record.
Below is an example of a custom subdomain setup:
Сhoose your container on Stape, scroll down, and click Add custom domain.

Add Subdomain name - it can be any name that works for you, just be sure to avoid using phrases specific to advertising or tracking: ad, gtm, stgm, tracking, analytics, metrics, stape, gtag, etc.
A Content Delivery Network (CDN) distributes your website's assets across a global network of servers to reduce latency and improve load times for users in different locations. It is useful if your audience is geographically distributed or if you want to improve cookie tracking and data accuracy.
By default, the CDN is disabled, which means JavaScript files (like gtm.js, gtag.js, and analytics.js) are served directly from the server location where your sGTM container is hosted. Effectively, it bypasses both Stape Global CDN and Own CDN options and gives you a direct, unproxied connection between your site and the sGTM container.
| Important: please consider your country's privacy regulations before setting up a CDN. |
To enable the CDN, click the Add CDN toggle and select one of the following options:


Next, in the How to connect section, there are two ways of connecting a custom domain to your container:

The easiest way to connect domains. Log in with your DNS provider details via Entri, and give us one-time permission to connect your domain. That's it, you can proceed directly to Step 5 to verify your domain; no manual configuration is required.

With this option, you have to add DNS records manually to your hosting provider to connect your subdomain to Stape.

After you add a custom subdomain to your container, you will see DNS records that should be created to verify the custom domain. The DNS record depends on the server location and the CDN option you choose. In the next step, we show how to add DNS records.
By default, subdomain verification is performed with CNAME records, but you can verify your subdomain with A and AAAA records if you need to (usually in cases when you need to avoid adding duplicated records).
We will cover both options below with a step-by-step guide on how to create records using Cloudflare. But you can use any other provider.
You must create one CNAME record if you do not use Stape Global CDN and two records if you use Stape Global CDN.
1. Log in to your domain name service and create a new DNS record for the subdomain you want to use. To do it, click three dots and choose Configure DNS next to your domain name on the account home page.

2. Click Add record.

3. Go back to your Stape account and input the record you see in the account. Make sure that the Proxy status is turned off.

We use Stape Global CDN, so we create two CNAME records:


| Please note that A/AAAA records are incompatible with enabled CDN. |
1. If you need to verify your custom subdomain using A and AAAA records, add the custom subdomain to the container and make sure that the CDN toggle is switched off.
Click Advanced settings and tick the Use A records instead of CNAME records box. You will see DNS records that you should add inside your Stape container. The DNS records you should configure vary depending on the server location.

2. Log in to your DNS account and add the records you see in your Stape account. On the account home page, next to your domain name, click three dots and choose Configure DNS.

3. Click Add record.

4. Then, create the records you see in your Stape account. Make sure that the Proxy status is turned off.
Take the values for your DNS records from the Stape account:

As a result, you will get two DNS records:


Once you've entered the DNS records to your DNS provider, return to the Stape container page where you've been configuring the custom domain and click Verify.

Wait for Stape to finish verifying your custom domain (when the container status bar changes from Verifying to Ready). Usually, it takes 2-3 hours to verify the custom domain. For some DNS providers, verifying records might take up to 72 hours. We will email you once the custom domain is verified or any error is detected.
If you face any problems with domain verification, please follow our guide on troubleshooting a custom domain.

Go to your Google Tag Manager server container → Admin → Container Settings → change Tagging server URL to your subdomain.

Update the script
If you use a custom domain, updating the Web GTM script on your website is highly recommended. This tweak will load gtm.js from your domain. To do so, replace the default domain googletagmanager.com with the custom domain you set up in the previous step.
Alternatively, you can automate this process with the Custom Loader power-up. Instead of manually editing the GTM script, Custom Loader generates a ready-to-use code snippet that loads GTM and GA4 scripts directly from your custom domain. This saves your time, makes your tracking scripts more resilient to ad blockers, and assures all cookies are treated as first-party.

Custom Loader modifies gtag.js and gtm.js loading paths to resist ad blockers and ITPs, potentially increasing data volume by up to 40%.
5.1 Find and copy your web GTM ID in GTM. To find GTM ID log in to your Google Tag Manager account and open a Web GTM container. In the top right corner (next to the Submit and Preview buttons) you’ll see some short text that starts with "GTM-" and then contains some letters/numbers.

5.2 Open your sGTM container on Stape → Click Power-Ups.
Find Custom Loader and click Use.

5.3 Add the following settings:
Domain - from the list of domains connected to your container, select the necessary ones.
Web GTM ID - add web Google Tag Manager ID. Check out how to find web GTM ID in our guide.
GA4 ad block bypass - enables bypassing adblockers' impact on the GA4 tracking code. Note that this setting will affect all container domains. Be sure to debug both the web and server GTM containers after enabling this toggle.
Same Origin Path - if you are using same origin approach for configuring custom domain, please specify the proxy path for requests.
Platform - the Custom Loader code differs for each platform. Select "BigCommerce".
5.4 Once you’ve entered all the Code & Setup information, click the Generate button.

5.5 Follow the instructions on the Configuration panel to set up Custom Loader in your app.
1. Install the Conversion Tracking app. Click Get this app → log in to your BigCommerce account → Install.

2. Then, you need to complete the settings parameters in three tabs: General, DataLayer, and Webhooks.
2.1 General tab
Here, you need to add the following data:
If you haven’t created a subdomain yet, please see our guide on adding a custom domain to sGTM container.
After setting all the necessary fields, click “Save”.

2.2 Data Layer tab
Here you can find a list of events and their payload, which is added via the App for BigCommerce.
In this tab, you can add two points to the settings:
Click “Save”.

2.3 Webhooks tab
The webhooks feature will be handy if you want to track events outside your website, such as sales made by phone or in offline stores. You just add or update information on a user in CRM or CMS, and the webhook sends data in GTM.
To activate a webhook, you need to choose the type of webhook, “Purchase” or “Refund” (or both), and then you can click on “Send webhooks to server GTM container”. Then, add your GTM server container URL (the path where the webhook will be sent).
Click “Save”.

There can be two scenarios:
4.1.1 Add your server container URL to Google Tag settings. In the configuration settings, add the configuration parameter server_container_url and add your tagging server URL as a value.

4.1.2 Create Google Analytics 4 client in server GTM container. To do so, open the clients’ section → Create New client → Select client type Google Analytics: GA4 (Web) → Add client name and click Save.

You can also read more on region-specific parameters in our blog.
4.1.3 In the server GTM container create a new tag with the tag type Google Analytics: GA4

4.1.4 Add Measurement ID and Event Name.
Measurement ID - follow this guide to find GA4 ID. You can add it as variable or if the event came from a GA4 web tag, you can leave this field blank to inherit the measurement ID of the event.
Event Name - the event name to send to Google. See the recommended events for more information. If this field is blank, the value of the event_name parameter will be sent.

4.1.5 Click Triggering and configure a trigger with the trigger type Custom that will fire every time when client name equals GA4 (or the name of the GA4 client that you’ve specified on the step 2.b) → Click Save.

4.2.1 Inside the Web container, create a new tag of the tag Type Google Tag. Add your Google Tag ID.
Add trigger to GA4 tag. It usually 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 tag manually.
These parameters can, for example, define whether you want to send a page view event every time a Google Tag triggers, set UTM parameters, set client ID, etc. There is a list of standard Google Tags configuration parameters.
4.2.2 To set up the GA4 event tracking, 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.


4.2.3 Go to your Google Tag Manager Server container. Click Clients and New.

4.2.4 Choose Google Analytics: GA4 (web) and click Save.

4.2.5 Go to Tags and click New.

4.2.6 Choose Google Analytics: GA4.

4.2.7 Add Measurement ID and Event Name.
Measurement ID - follow this guide to find GA4 ID. You can add it as a variable or if the event came from a GA4 web tag, you can leave this field blank to inherit the measurement ID of the event.
Event Name - the event name to send to Google. See the recommended events for more information. If this field is blank, the value of the event_name parameter will be sent.

4.2.8 Click Triggering.

4.2.9 Create triggers for the tag. Client name should equal GA4. Example:
Click +

Choose Custom type → click Some events → choose Client Name in built-in variables → set Equals GA4 (the name of your GA4 client) → click Save.

4.2.10 Open web and server GTM debuggers and test the setup.
Open the Server container preview mode and check that you see GA4 requests. Publish updated inside server and web Google Tag Manager containers.

Add the following record inside your Google Tag in the web Google Tag Manager container.
Configuration parameter: server_container_url
Value is your domain name in Stape admin


We suggest starting with the Tag Manager preview and debug mode to ensure that your tags are triggering when they should. GTM debug tool will show you which tags and events were added to the site and whether they fired or not on particular pages/triggers.
Tag manager server container debug mode works similarly to web debugger. Just click the preview button on the top right corner. Then, navigate to the different pages and click on the button or perform events set up in the server container.
Return to the Tag Manager debugger and check which tags and events were triggered and if all required parameters were sent to the dataLayer. If everything works correctly, we can move to the next step.

GA4 has it's debug view that will show you all events, event parameters and user data that we processed by GA4. To find GA4 debugger click Configure → Debug view.

To ensure that requests are sent from a custom tagging URL, you’ll need to dive deeper into the developer’s zone. We’ll need Chrome or Safari developer tools here (you can use other browsers as well).
On Mac, you can access the developer tool by clicking command+option+I or click the right mouse button, then Inspect.

Once you’ve opened the developer tools, go to the Network tab and refresh the page. Use the filter and type collect to find GA4 requests. Click on a GA4 request and check the Request URL and parameters on the right to confirm that hits are being sent to your server-side tagging domain (the same URL configured in the server container and GA4 tag/variable).
Keep in mind that you may not see collect requests if GA4 ad block bypass is enabled. In that case, it’s recommended to look for requests directly via your server-side subdomain (for example, sst.testdns.io) instead of relying on the default collect filter.

Note: cookies will be extended only if you are using a custom subdomain inside the tagging URL. For instance, your website URL is example.com. Then, the custom domain for tagging URL should look like gtm.example.com.
Go to the application tab inside the developer tool that you’ve used in step two. Click Storage → Cookies. On the right side, you will find cookies named FPID; check the date in the column “expires”. This way, cookies should be extended up to 2 years. I am writing this post in February 2021, and my cookie will expire in February 2023. If you are not using server-side tracking and a custom tagging URL located under your main domain, Safari will decrease your cookie lifetime to 1 or 7 days. If you see that cookies were not extended, go to the GA4 client inside the server container, click more settings and check what Server Cookie Settings look like on the screenshot below. Or make sure that you are using a custom tagging URL that looks like gtm.yourdomain.com.

Setting up server-side Google Analytics 4 for BigCommerce website is an effective way to obtain the most precise data and, hence, make data-driven decisions. The setup process is easy as a breeze and takes a few steps to complete.
If you’ve had difficulties with the installation process, feel free to email Stape’s support team at support@stape.io, and we will be happy to assist you.
We are happy to hear that! Click on Try for free to register and check all the possibilities.
Subscribe for updates:
we don’t spam!Blog
Enhance BigCommerce ad performance with Facebook CAPI via sGTM. Implement event deduplication and precise tag configurations for improved conversion tracking.
Blog
Google Tag Manager server container has close integration with Universal Analytics. When you set up GTM server tagging, you will see that Universal Analytics Client is created by default. In this article, we will discuss the benefits and possibilities that server-side Google Analytics offers. And also, how to configure Google Analytics in your Google Tag Manager Server account.If you don’t have a GTM server container yet, please follow this instruction on how to launch it on your website. If you are still not sure what GTM server tagging is and how it can benefit your website tracking system, please read this blog post.
Blog
Conversion Tracking app for BigCommerce: easily add GTM, Cookie Keeper, dataLayer events, and webhooks to your store. Enhance tracking accuracy and website performance.

Comments