Step 1: Creating Your Server-Side Container
- Log into your Google Tag Manager account.
- Create a new container and select the type “Server”.
- Give your container an appropriate, descriptive name.
Step 2: Configuring Cloud Servers on Google Cloud
- Within your GTM Server-Side container, select “Automatically provision tagging server”.
- Sign in to your Google Cloud Platform account when prompted.
- Follow the automated setup prompts, choosing your desired server location (region) and scaling settings (typically start with recommended defaults).
- Note: If you wish to use a custom domain, Google Cloud allows easy integration of your domain via DNS records, enhancing brand consistency and user trust.
Step 3: Migrating Existing Tags to Server-Side
Identify Tags for Migration:
- Review your current Google Analytics 4 (GA4) tags in your client-side GTM container.
- Note essential configurations such as Measurement ID, events, and custom parameters.
Create Server-Side Tags:
- In your server-side GTM container, click “New Tag”.
- Select the tag type “Google Analytics: GA4”.
- Enter your GA4 Measurement ID.
- Define event parameters clearly. For instance, for an “Add to Cart” event:
- Event Name:
add_to_cart
- Parameters:
item_id
: Product identifier (e.g., SKU)
item_name
: Product name
currency
: Currency code (e.g., GBP)
value
: Product value
- Specify user properties such as user ID or membership level, if required.
Configure Client-Side to Server-Side Communication:
- Open your client-side GTM container.
- Modify your existing GA4 tags:
- Under Tag Configuration, locate the “Send to server container” or “Transport URL” option.
- Enter the URL of your newly provisioned server-side tagging endpoint (e.g.,
https://gtm.example.com
).
- Save and publish these changes in your client-side GTM container.
Test and Validate:
- Activate Preview mode in both client-side and server-side GTM containers.
- Trigger events on your site (e.g., add to cart, page view).
- Verify the tags fire correctly and data transfers seamlessly from the client-side to your server-side container.
- Confirm data accuracy within your GA4 real-time reports and debugging tools.
Testing and Validation
- Use GTM’s Preview mode to ensure tags trigger correctly.
- Verify data integrity and server response times.
- Validate data in analytics platforms or reporting tools.