Google Tag Gateway
Akamai’s Google Tag Gateway (GTG) behavior lets you serve Google tags from your first-party domain at the edge rather than Google’s third-party domains. GTG lets you deliver tags directly onto your Akamai-accelerated hostnames, bypassing tracking restrictions associated with third-party tag injection and enforced by modern browsers.
Use this behavior to deploy and deliver one or more Google tags from within your existing delivery configuration. For more information on Google Tag Gateway, see our official documentation: Welcome to Google Tag Gateway.
Before you begin
Note that once you provide all the required data in the behavior, we ask you to acknowledge the following mandatory legal disclaimer:
I acknowledge and agree that by enabling Google Tag Gateway, I authorize Akamai to forward certain cookies set by Google Tag Gateway, and certain HTTP request headers, including User-Agent and browser client hints, to the Google Tag Manager endpoints for the performance of Google Tag Gateway and any other downstream system Google may use the data for in accordance with its privacy policies. I confirm that I am authorized to enable this feature on behalf of my organization and that my organization has implemented any required end-user disclosures and obtained any necessary end user consent in accordance with applicable data protection laws. I understand that Akamai acts as a data processor on my organization's instructions and that Google processes the data it receives as an independent data controller, solely responsible for its compliance with applicable data protection laws, and uses the data it receives when providing the Google Tag Manager services for that service and their own purposes.
How it works
Traditionally, Google tags are served from third-party domains. This lets browsers and ad blockers more easily block requests to those domains, and can lead to inaccurate conversion rates.
The GTG behavior deploys your Google tag(s) as if they were on your own domain, also known as a first-party approach. GTG loads and uses your tags at the edge, effectively “shielding” your analytics from aggressive ad blocking and cookie-capping logic of modern browsers. See: How it works in our Google Tag Gateway documentation.
A correct setup of the Google Tag Gateway behavior includes:
- A rule to match on the serving path used as the tag endpoint.
- Tags injected on pages of your site by either Property Manager or your own tag management solution. That uses the configured path. See Tag injection methods.
- An out-of-the-box Google tag uses
https://www.googletagmanager.com/gtag/js?id=TAG_IDas itssrcscript, where thesrcattribute is the URL of the external JavaScript file used for tracking. With Google Tag Gateway configured, replace this with your configured path. For example,https://my.domain.com/abc123. - If injecting more than one Google tag, you need one parent rule with no match criteria, and child rules configured for each individual tag. See Multiple Google tags.
You can only have one instance of the behavior per rule. If your property has this behavior on multiple rules, only the last rule that matches the incoming request is applied.
You can’t use the behavior's Re-tag my page to use Akamai option to inject more than one tag on a given page.
Products that use this behavior
You can create a custom rule and configure the Google Tag Gateway behavior inside a hostname match for the Ion, Dynamic Site Accelerator, and API Acceleration products.
Incompatible behaviors
The following Akamai behaviors are incompatible with the Google Tag Gateway behavior.
If you need these behaviors for your specific delivery configuration, contact your account team to help optimize your setup. See Troubleshooting: Conflicts with existing behaviors for more information:
If you’re using a third-party tag management system like Google Tag Manager, Adobe Experience Platform (AEP), or Tealium, you don’t need to disable or remove these behaviors.
Restrictions
The following restrictions apply when using the Google Tag Gateway and EdgeWorkers behaviors on the same property:
- If you use request.respondWith to construct a response in your EdgeWorkers function, Google Tag Gateway will not be applied to the response.
- To use responseProvider with createResponse, you need to include the text/html content-type. If you do not include this content-type, Google Tag Gateway will not insert the defined tags.
Features and options
| Field | What it does |
|---|---|
| Enable | Enables the Google Tag Gateway behavior. |
| Google tag ID | Specifies the unique Google tag ID that you get from Google. |
| Serving Path | Specifies the path on your site that serves the Google Tag. It should:
|
| Send True Client IP Header | Sends the True Client IP header to the Google origin. |
| Re-tag my page to use Akamai | Injects the Google tag script directly into the page. Enable this if your pages don't already include the Google tag script. |
| Is your website already tagged with Google? | Controls whether the injected tag should override any on-page configuration. Enable this if your pages don't already include the Google Tag script. |
Advanced options
Enable Advanced options in the Google Tag Gateway behavior to get fine-grained control of your tag deployment:
- Send True Client IP Header. True Client IP is a custom HTTP request header. When this option is enabled, Akamai uses this header to pass the end user’s actual IP address to the Google origin instead of the IP address of the Akamai edge server used to serve the request. This helps make sure the correct visitor IP is used for your Google tag data tracking.
- Re-tag my page to use Akamai. When enabled, this option allows Akamai to automatically inject the Google tag script into your HTML page responses. If this option is turned off, you need to handle the injection of the Google tag JavaScript using a different method (for example, direct HTML or your existing tag manager).
- Is your website already tagged with Google? This option controls whether the injected tag should try to override existing on-page tag configurations. By default, this option is set to Off per Google’s recommendation. Keeping this option disabled ensures seamless integration with existing tag management frameworks and consent platforms.
When Advanced options are disabled, the configuration defaults to the following settings in the background:
- Send True Client IP Header = On
- Re-tag my page to use Akamai = Off
- Is your website already tagged with Google? = Off
As a best practice, the Is your website already tagged with Google? option should remain disabled and set to Off. This setting is not required for existing Google customers using Google Tag Gateway, and keeping it disabled helps ensure seamless integration with your current tag management and consent frameworks.
Implementation
- Log into Control Center.
- Navigate to the property or include on which you want to add the Google Tag Gateway behavior. Alternatively, you can create a new property. If creating a new property, see Workflow overview.
- To add the Google Tag Gateway behavior to your property or include, see Use cases.
- Activate your property on the staging network. Deploy your property version on the servers in the Akamai Edge Staging Network (ESN) so that you can test the configuration.
- Test on staging. Set up and run tests against the staging configuration. Once you confirm that your configuration works as expected, you can perform regression and load testing outside of Property Manager as needed.
- Activate your property on the production network. Deploy your configuration version to the Akamai Production network to prepare to go live.
Use cases
Single Google tag
If you’re deploying a single Google tag, you can use either the GTG behavior in your delivery rule configuration or the one-click GTG option within Google’s Google Tag Manager interface. For more information, see our Google Tag Gateway documentation.
For information on using the GTG one-click option on Google, see Google’s official documentation: Set up Google tag gateway for advertisers using Akamai
Follow these steps to configure the GTG behavior for injecting one Google tag:
- In your rule configuration, add and name a new blank rule template. For example, "Google Tag".
- In the rule’s match criteria, select Hostname, and add your domain. For example,
www.example.com. - Add the Google Tag Gateway behavior to your rule.
- Enable the behavior.
- Add your Google tag ID (provided by Google) and Serving Path.
- Under Advanced Options, choose if you want to use the True Client IP header for data tracking, if you want to inject your tag using Akamai, or if you want to inject your tag using another platform. See Advanced options.
- Add a child rule matching all sub-paths of the tag's serving path, for example
/abc123/*, with behaviors to:- Disable Edge Redirector Cloudlet if enabled within the configuration.
- Allow POST requests.
Multiple Google tags
If your site configuration requires multiple Google tags (one per page), you need to create a new, blank parent rule with no match criteria, and then configure a separate rule for each Google tag with the Google Tag Gateway behavior in each rule.
- In your rule configuration, add and name a new parent rule with no match criteria. For example, "Google Tags".
- Next, add child rules for each of your Google tags. Each rule should match only for the intended hostname and serving path.
- In every child rule, add and configure your match criteria. For each match, select type Hostname, and then specify your domain. Then add a match path specifying the serving path for the individual Google tag.
- Add and enable the Google Tag Gateway behavior in each child rule.
- In each child rule’s GTG behavior, specify the Google tag ID (provided by Google) and Serving Path for each individual tag.
- Under Advanced Options, set both the Re-tag my page to use Akamai and Is your website already tagged with Google? options to Off.
- Under your parent rule, add a separate child rule matching wild-card sub-paths to serving paths, for example
/abc1/*, /abc2/*, that includes behaviors to:- Disable Edge Redirector Cloudlet if enabled within the configuration.
- Allow POST requests.
You can’t use the behavior's Script Injection option to inject more than one tag on any given page.
Tag injection methods
When determining how you want your tags injected, choose one method. Injecting your Google tags from multiple sources may lead to unexpected results, including incorrect data tracking or compliance issues.
Tag injection is how Google tags get placed onto your site without editing your site's source code. Depending on your requirements you have several options for how you want your tags injected: Akamai script injection, third-party, or direct HTML editing
Akamai script injection
Use either the Google Tag Gateway one-click option in Google or the Google Tag Gateway behavior. In the GTG behavior, enable the Re-tag my page to use Akamai option under Advanced options. The Akamai CDN adds the <script> tag to your HTML page responses before sending them forward to the client. You can inject one tag per-page using this method.
When to use this method:
- You want to inject your tag(s) at the edge
- You only need to inject one tag per page
- You’re not using an existing tag manager
- You’re not using a Consent Management Platform (CMP)
Third-party
Use Google Tag Manager or another third-party system to inject your tags. Replace the URL in the out-of-the-box Google Tag snippet with the URL and a path configured by the behavior.
In your tag manager, modify the Google tag snippet to use your serving path instead of Google’s domain. Replace instances of www.example.com/abc123 with your domain and serving path, and replace G-XXXXXXXX with your Google tag ID:
<script async src="https://www.example.com/abc123/gtag/js?id=G-XXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXX', {
'transport_url': 'https://www.example.com/abc123',
'first_party_collection': true
});
</script>
When to use this method:
- You’re already using a third-party tag manager to inject more than one Google tag.
- You need to inject more than one tag per page, or you need granular control over which pages load which tags.
- You’re using a CMP or have specific compliance needs (for example: conditional loading based on triggers and consent state).
Adobe Experience Platform (AEP) usersIf you’re using Adobe for your tag injection, see Adobe’s official documentation.
Direct HTML editing
You can use any Content Management System (CMS) to add your tags directly to the HTML of your pages. Replace the URL in the out-of-the-box snippet with the URL and a path configured by the behavior.
Replace instances of www.example.com/abc123 with your domain and serving path, and replace G-XXXXXXXX with your Google tag ID:
<head>
<!-- Google Tag via Akamai Gateway -->
<script async src="https://www.example.com/abc123/gtag/js?id=G-XXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXX', {
'transport_url': 'https://www.example.com/abc123',
'first_party_collection': true
});
</script>
</head>
For more information on direct HTML editing, see our Google Tag Gateway: Troubleshooting documentation.
Tag injection tips
Things to consider when choosing your Google tag injection method:
- If your website uses multiple Google tags per page or a tag management solution, we recommend managing tag injection directly within your existing platform rather than through Akamai.
- If you need to inject more than one Google Tag at the page level, only a single tag can take effect. To avoid unexpected behavior when using multiple Google tags, you should rely on your tag manager or application platform to control how and when tags are injected.
- Don’t use Akamai-based tag injection when using a Consent Management Platform (CMP) alongside a tag manager. Injecting Google tags outside of your existing workflow may bypass or override your consent settings, which could impact your privacy and compliance controls. Managing tags within your tag manager ensures that your consent preferences are always respected.
If you have questions about the best configuration for your tag injection, contact your account team to help you determine the optimal setup.
Updated about 1 hour ago
