Question

How can I manually set up a Google Tag Manager (GTM) server-side on Digital Ocean?

Hi,

I want to use Server Side in Google Tag Manager because it will improve my meta pixel a lot and it will reflect on my ads performance. But I don’t want to use google cloud platform either.

We have two options for this. Google can make an automatic connection for you on the Google Cloud Platform. The second option is to install it manually on your server. There is no content that fully explains how to install it manually. There is only google’s document. Let’s look at the document.

https://developers.google.com/tag-platform/tag-manager/server-side/manual-setup-guide

https://streamable.com/qftywd

I realized that I needed to install docker and installed docker on my server.

In my video I type the following command and it seems to work. sudo systemctl status docker

I installed gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable that google asked for by typing docker images.

The last time I test it. In the code below, in the <config_string> field I write the Container Config I got from gtm-server.

docker run -p 8080:8080 -e CONTAINER_CONFIG=‘’ -e RUN_AS_PREVIEW_SERVER=true gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable

I’m sending a request to the link below but I’m not getting a response. I only want 200. http://localhost:8080/healthz

What do you think the reason is? I’ve been thinking about it for days. What could I have missed? Actually, it seems simple. Install Docker. Install images from Google. Preview at the end. But I can’t get 200.

I also couldn’t find any other content about it, although it must be very important to open gtm-server somewhere other than gcp.

I am grateful to friends for their support.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
February 29, 2024

Heya,

Setting up Google Tag Manager’s (GTM) server-side tagging manually on your own server can be quite complex, and it’s important to ensure all steps are correctly followed. Based on your description, you’ve made significant progress by installing Docker, pulling the Google image, and attempting to run it. Let’s go through some common troubleshooting steps that might help you resolve the issue of not receiving a 200 response from http://localhost:8080/healthz.

1. Verify the Docker Container is Running

First, ensure that the Docker container with the GTM server-side image is running:

docker ps

This command lists all active containers. Check if the GTM container is listed and is not exiting/restarting.

2. Check Docker Container Logs

Inspect the logs of your Docker container to see if there are any error messages or logs that might indicate what’s going wrong:

docker logs [container_id]

Replace [container_id] with the ID of your GTM container.

3. Correct Configuration String

Make sure the CONTAINER_CONFIG environment variable is set correctly in your docker run command. It should be the exact configuration string you got from GTM server. The string should be enclosed in single quotes without extra spaces:

docker run -p 8080:8080 -e CONTAINER_CONFIG='your_config_string' -e RUN_AS_PREVIEW_SERVER=true gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable

4. Network Configuration

If you’re running this on a server and testing it from a different machine, localhost will refer to the local machine, not your server. In this case, use the server’s IP address or domain name instead of localhost. If you’re running this directly on the server, localhost should be fine.

5. Firewall or Network Issues

Ensure that your server’s firewall settings allow traffic on port 8080. If you’re running a cloud server, also check the network security group or equivalent to ensure the port is open.

6. Docker Port Mapping

The -p 8080:8080 argument in the docker run command maps the container’s port 8080 to your host’s port 8080. Verify that this port mapping is correct and that no other service is using port 8080 on your host machine.

7. HTTP vs. HTTPS

Ensure you are using the correct protocol. If your server is set up to redirect HTTP to HTTPS or only accept HTTPS connections, trying to access http://localhost:8080/healthz might fail. Try using https://localhost:8080/healthz in that case (although for localhost, this is less likely to be the issue).

8. Docker Image Updates

Check if there are any updates to the Docker image provided by Google. Sometimes, pulling the latest image can resolve issues:

docker pull gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable

Then, rerun your container with the updated image.

Conclusion

If after these steps, you’re still facing issues, the container logs are usually the best place to look for more specific errors. Since this is a relatively specialized setup, the community around GTM server-side tagging might be limited

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.