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

- Author: Mert Enercan (https://merto.dev)
- Published: 2024-10-18
- Language: en
- Tags: google-tag-manager, azure, usehardal, gtm-server-side, cloud
- URL: https://merto.dev/blog/server-side-gtm-with-azure-app-service/
- Originally published: https://medium.com/usehardal/server-side-gtm-with-azure-app-service-02047bc59bba

---

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 a [container app](https://azure.microsoft.com/en-us/products/container-apps) on Azure. After that, we map the container app to our desired custom domain. You can accomplish this with a single click on [_Hardal_](https://usehardal.com/?utm_source=merto.dev&utm_medium=referral&utm_content=blog_server-side-gtm-with-azure-app-service).

![](https://cdn-images-1.medium.com/max/1024/1*mwJlIyzXsU9b0N1qj2zQXQ.png)

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

![](https://cdn-images-1.medium.com/max/1024/1*WKXTK56cQrIsWug2mzaBow.png)

### The Plan

-   Create a server-side GTM and obtain a configuration key
-   Set up a server-side GTM [container registry](https://azure.microsoft.com/en-us/products/container-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.

![](https://cdn-images-1.medium.com/max/758/0*xwk2Mg_63QGSHDzs.png)

As always, let’s start with the basics of server-side GTM infrastructure. This diagram is from the official [Google documentation](https://developers.google.com/tag-platform/tag-manager/server-side/manual-setup-guide). 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.

```ts
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!

* * *

[Server-side GTM With Azure App Service](https://medium.com/usehardal/server-side-gtm-with-azure-app-service-02047bc59bba) was originally published in [Hardal](https://medium.com/usehardal) on Medium, where people are continuing the conversation by highlighting and responding to this story.
