Server-side GTM With Azure App Service
Explore implementing server-side Google Tag Manager using Azure App Service, using Hardal for improved performance, better data accuracy, and enhanced user privacy.
Hello, everyone!
Explore implementing server-side Google Tag Manager using Azure App Service, using Hardal for improved performance, better data accuracy, and enhanced user privacy.
As always, let's start with the basics of server-side GTM infrastructure. This diagram is from the official Google documentation. I won't go into the details of how it works, but it's essential to understand the framework of what we are doing.
- We need to set the Ingress value to "enabled" to access our Container App with a domain.
- We need two container apps: one for the preview server and one for the tagging server. Environment values vary depending on the container type.
Preview Server Environment Variables
CONTAINER_CONFIG='<config string>'
RUN_AS_PREVIEW_SERVER=true
Tagging Server Environment Variables
CONTAINER_CONFIG='<config string>'
PREVIEW_SERVER_URL='<HTTPS preview server url>'
`
Type: CNAME
Name: www or {subdomain}
Value: <DNS VALUE THAT AZURE PROVIDES>
Type: TXT
Name: asuid.www or asuid.{subdomain}
Value: <DNS VALUE THAT AZURE PROVIDES>
After a short delay, our container will be accessible via our custom domain!
With everything set up, you're now ready to leverage server-side GTM on Microsoft Azure with your custom domain. This setup not only enhances your tracking capabilities but also ensures better performance and flexibility.
Happy tracking!