Google tag gateway legacy setups

Fill in the following to populate the examples throughout this document.

Your domain: example.com
Google tag ID: G-12345
Tag serving path: /metrics

Cloudflare Enterprise

To serve your tag in Google tag gateway for advertisers, you will create a CNAME entry for a new subdomain, create an Origin Rule to forward requests, and create a Transform Rule to include geolocation information. To complete this setup, you will need to have a Cloudflare Enterprise plan. If you don't have an Enterprise plan, consider using the Cloudflare in-UI setup instead.

Create CNAME entry

Choose a subdomain to reserve for the CNAME entry. Fill in the following to populate the examples throughout this document. This CNAME is never exposed outside your Cloudflare configuration, so the name is arbitrary.

CNAME subdomain: fps
  1. In the DNS tab, open the Records section.
  2. Add a new record with the following configuration:
    • Set Type to CNAME.
    • Set Name to fps.
    • Set Target to G-12345.fps.goog.
  3. Save the CNAME record.

Create the Origin Rule

  1. In the Rules tab, open Origin Rules and create rule.
  2. Enter a rule name, such as Route measurement.
  3. Match incoming requests based on a Custom filter expression and click Edit expression.
  4. Paste the following expression in the builder: (http.host eq "example.com" and starts_with(http.request.uri.path, "/metrics"))
  5. Update the Host Header to Rewrite to... G-12345.fps.goog.
  6. Update the DNS Record to Override to... fps.example.com.
  7. Save the Origin Rule.
  8. If there are other Origin Rules, increase the newly created Rule's position so that it will run after any other wildcard paths.
  9. In a browser, verify the setup by navigating to: https://example.com/metrics/healthy. The page should read ok.

Include geolocation information

  1. In the Rules tab, open Settings
  2. Enable the Add visitor location headers option.
  3. Wait a few minutes for the rule to propagate. In a browser, verify the set up by navigating to: https://example.com/metrics/?validate_geo=healthy. The page should read ok.