Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Hardal profile imageMert Enercan
Mert Enercan forHardal

Posted on • Originally published atusehardal.com

     

Server-side GTM With Azure App Service

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.

TL:DR
We create a container registry and acontainer app on Azure. After that, we map the container app to our desired custom domain. You can accomplish this with a single click on*Hardal.

Your Server-side GTM Container is one-click away!

The Plan

  • Create a server-side GTM and obtain a configuration key

  • Set up a server-side GTMcontainer registry on Azure.

  • Create a container app on Azure that runs the server-side GTM registry.

  • Map a custom domain to the server-side GTM container app.

As always, let’s start with the basics of server-side GTM infrastructure. This diagram is from the officialGoogle 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.

Deployment Details

We need to focus on two important topics when deploying our container:

  1. We need to set the Ingress value to "enabled" to access our Container App with a domain.

  2. 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

DNS Mapping

For the final step, we need to configure our domain to point to the container app. By selecting “Managed Certificate,” we need to add two DNS records to our domain.

Type: CNAMEName: www or {subdomain}Value: <DNS VALUE THAT AZURE PROVIDES>Type: TXTName: asuid.www or asuid.{subdomain}Value: <DNS VALUE THAT AZURE PROVIDES>
Enter fullscreen modeExit fullscreen mode

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!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Clarify your data for better analytics

More fromHardal

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp