DEV Community

Mert Enercan for Hardal

Posted on • Originally published at usehardal.com

Server-side GTM With Huawei

Hello everyone!

Let’s explore implementing server-side Google Tag Manager using Huawei Cloud Turkey, using Hardal for improved performance, better data accuracy, and enhanced user privacy.

TLDR

We utilized Cloud Container Instance (CCI) to deploy the server-side GTM container image, configured Elastic Load Balancer (ELB) and CCI Service for each workload, and created a DNS record using the ELB public IP.

The Plan

At the end of the day, we require a total of two running containers for the server-side Google Tag Manager.

  • One for Preview Server

  • One for Tagging Server

For this project, we chose to utilize the Cloud Container Instance (CCI) service on Huawei Cloud. This service is designed to run containerized applications, which perfectly aligns with our requirements. For more detailed information on how server-side Google Tag Manager functions, please refer to the official documentation.

Here is the full workflow:

1 — Import the Google Tag Manager image into Huawei Cloud’s Software Repository for Container (SWR).

2 — Set up a Preview Server CCI Workload using the imported SWR image.

3 — Configure Elastic Load Balancer (ELB) for the Preview Server workload

4 —Create a DNS record for the Preview Server.

5 — Deploy the Preview Server using CCI.

With these five steps, the preview server is successfully running on Huawei Cloud! We will repeat this process for our tagging server, with the only difference being that we will use the preview server’s URL as an environment variable in the tagging server’s image. Here’s the flowchart:

Managing SSL Certificates

Managing SSL certificates for the custom domain was the most challenging part of the entire process. Fortunately, with Certbot and Let’s Encrypt, we are able to generate free SSL certificates and store them in Huawei Cloud, allowing us to incorporate them into our CCI service configuration files.

In conclusion, the successful implementation of server-side Google Tag Manager on Huawei Cloud would not have been possible without the support of the Huawei team. Their assistance and expertise have been invaluable throughout this process. We are grateful for their guidance, which has significantly contributed to our project’s success. Thank you, Huawei team, for your continued support!

Until next time!

Top comments (0)