How can we help?

How to add custom domain

Ivanna
Ivanna
  • Updated

 

1. Log in to your Stape account, choose a container, scroll down and click Add custom domain.

 

Знімок екрана 2024-12-26 о 11.28.02.png

 

2. There are two ways of adding custom domain:

 

  • Automatically (via Entri)

 

Знімок екрана 2024-12-26 о 11.27.25 копія.png

 

This is the easiest way to connect domains.
Log in with your DNS provider details via Entri, and give us one-time permission to connect your domain. Check the full list of supported DNS providers by Entri.

 

entri.png

 

  • Manually

After you add a custom domain to your container, you will see DNS records that should be created to verify the custom domain. The DNS record depends on the server location and CDN option you choose.

  • Disable CDN - choose not to use any type of CDN.
  • Stape Global CDN - loads scripts from a server closer to a user visiting your website.
  • Own CDN - helps route sGTM custom domain and proxy sGTM traffic through the DNS provider of your website. In this case, the IP addresses of your website and the custom domain of the sGTM will match, and server-side cookies will be considered as first-party. As a result, it gives the ability to increase cookie duration.

 

Adding a custom domain with CNAME record.

 

You must create one CNAME record if you do not use Global CDN.

 

CNAME record WITHOUT Global CDN.png

 

You must create two CNAME records, if you use Global CDN.

 

CNAME record FOR Global CDN.png

Below there’s a step-by-step guidance on how to create records using Cloudflare.
But you can use any other provider

 

1. Log in to your domain name service and create a new DNS record for the subdomain you want to use. 

 

DNS record for the subdomain WITHOUT Global CDN.png

 

If you use Global CDN, set additional CNAME record

 

DNS record for the subdomain FOR Global CDN.png

 

2. Once your custom domain is verified, you should see the status ready below the tagging server URL in the stape admin. If there are any problems with verifying a custom domain, please follow this guide on troubleshooting a custom domain.

 

see the status ready.png

 

3. Go to your Google Tag Manager Server container -> Admin -> Container Settings -> Change Tagging server URL to your subdomain.

 

Change Tagging server URL to your subdomain.png

Adding a custom domain with A and AAAA records.

 

If you want to verify your custom subdomain using A and AAAA records, you can do so by clicking Advanced settings after adding the custom subdomain to the container and ticking the “Use A records instead of CNAME records” box.

1. Open your sGTM container on Stape, scroll down to “Domains” and click Add custom domain.

 

Add custom domain for with A and AAAA records.png

 

2. Write a custom domain. Click Advanced settings after adding the custom subdomain to the container and ticking the “Use A records instead of CNAME records” box.


3. The DNS records you should configure vary depending on the server location. You will see DNS records that you should add inside your stape.io container.

 

 

4. Log in to your DNS account and add records you see in your stape.io account. Below is an example of DNS setup for CloudFlare. Open the DNS setting of the required domain and click Add record.

 

Add DNS record in Cloudflare with A and AAAA records.png

 

 Then, create the records you see in your stape.io account. Ensure that the proxy is turned off.

 

Record for A.png

 

Record for AAA.png

 

Usually, it takes 2-3 hours to verify the custom domain. For some DNS providers, verifying records might take up to 72 hours. We will email you once the custom domain is verified or any error is detected. If there is an error with the verification, please follow this instruction on how to verify custom domain verification.

 

5. Once the custom domain is verified, go back to the Google Tag Manager Server container → Choose your server container → Admin → container settings → paste tagging server URL.

 

Paste tagging server URL with A and AAAA records.png

 

Update the script

If you use a custom domain, updating the Web GTM script on your website is highly recommended. This tweak will load gtm.js from your domain. To do so, replace the default domain googletagmanager.com with the custom domain you set up in the previous step.


An even better solution would be to use a Custom Loader power-up.

 

 

Same origin custom domain for sGTM

Google has recently changed the preferred way of mapping a custom domain for the server Google Tag Manager container. Instead of using a subdomain (like sgtm.example.com) they encourage using the same origin (like example.com/sgtm). 

With the same origin custom domain for sGTM, you will have the main benefit of server-side tagging - setting up first-party cookies. And with the tagging server using the same origin domain, you do not need to configure any additional settings to prolong cookies. However, mapping the same origin will be more complicated than configuring a subdomain.

You can learn more about this method in this article: https://stape.io/news/a-new-way-to-set-up-a-custom-domain-in-server-gtm 

And that's it! You can find out more in our article on how to add a custom domain to the Google Tag Manager Server container and if you need help, just contact us

Was this article helpful?

4 out of 9 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.