Documentation Fundamentals

Configuring BunnyCDN for a Same-Origin Server-Side GTM Setup

How to configure Bunny CDN for a first-party, same-origin SGTM setup with owntag.

Serving your Server-Side Google Tag Manager from the same IP address as your website provides significant advantages for cookie longevity and reduces the risk of your tracking being limited by adblockers.
If you use Bunny as your Content Delivery Network (CDN), the configuration is particularly straightforward. As a European CDN provider, Bunny is also especially privacy-friendly.

Goal

Data flow diagram for Bunny CDN same-origin configuration

The goal of these settings is to serve your Server-Side GTM from a directory within your website’s domain. If your website is served at https://www.example.com/, your Server-Side GTM should be served at https://www.example.com/data/ or another directory.

Before you start, you should decide on a directory name. This could be /data/, /sgtm/, or something similar. We advise against using tracking-specific names like /collect/ or /tracking/, as they may be blocked by adblockers.
Also, coordinate with your IT team beforehand to ensure the directory is not already in use for other purposes.

Bunny Configuration

In the “CDN” menu, select your website’s Pull Zone. In our example, it’s named owntag-website.

Selecting the website's pull zone in the Bunny CDN dashboard

Go to the “Edge Rules” section in the Pull Zone settings. Then, in the “Actions” section, add the following rules.
The order of the settings is not important.

Change Origin URL

  • Type: Change Origin URL (Origin)
  • Origin URL: https://45e1dd14-8a8d-49bf-9e92-e523f98fc992.owndn.eu/%{Path.*}

Insert the owntag default hostname of your owntag SGTM container here. You can find it in owntag under the “Domains” section. It ends with .owndn.eu. Then, verify that the value you entered for “Origin URL”:

  • starts with https://
  • ends with /%{Path.*}

Set Request Header

  • Type: Set Request Header (Origin)
  • Header Name: Host
  • Header Value: 45e1dd14-8a8d-49bf-9e92-e523f98fc992.owndn.eu

Enter your owntag default hostname here again. In this field, however, without https:// and without /%{Path.*}.

Bypass Perma-Cache

  • Type: Bypass Perma-Cache (Origin)

Disable Bunny Optimizer

  • Type: Disable Bunny Optimizer (Cache)

Disable Bunny Shield Challenge

  • Type: Disable Bunny Shield Challenge (Origin, Cache)

Disable Bunny Shield Bot Detection

  • Type: Disable Bunny Shield Bot Detection (Origin)

Disable Token Authentication

  • Type: Disable Token Authentication (Cache)

Disable WAF

  • Type: Disable WAF (Origin)

Override Cache Time

  • Type: Override Cache Time (Origin, Cache)
  • Cache Time in Seconds: 0
Configuring the list of actions for the Bunny Edge Rule

Important: All of these actions must be linked to a condition to ensure they only execute for the chosen directory. Scroll down to the “Conditions” section and configure the following setting:

Condition

  • IF: Match any
  • Request URL: https://www.example.com/data/*
Configuring the condition for the Bunny Edge Rule

Replace https://www.example.com/data/* with your own domain and your desired directory. The asterisk (*) at the end is important as it acts as a wildcard, capturing all subdirectories and paths within the /data/ path.

Examples of valid directory URLs:

  • https://www.example.com/data/* (for the /data/ directory)
  • https://www.example.com/sgtm/* (for the /sgtm/ directory)
  • https://shop.example.com/measurement/* (for a subdomain with a /measurement/ directory)

This condition ensures that the Edge Rules only apply when a request is made to the specific directory where your Server-Side GTM is intended to run.
All other requests to your website will be delivered normally via Bunny without applying the SGTM-specific settings.

Save & Test

Click “Save Edge Rule” to save the settings.

Finally, go to your Server-Side GTM container settings at tagmanager.google.com under Admin > Container Settings and enter the URL including the directory name, for example, https://www.example.com/data (without any trailing slash):

Setting the container's server container URL in Google Tag Manager

After saving the settings, you can now activate the preview mode of the Server-Side GTM container. When you open your website in a separate browser tab, you should see incoming requests to your Server-Side GTM container.

Verifying the setup in Server-Side GTM's preview mode