Skip to Content
Tag ManagerTagsGoogle Analytics 4 Tags

Google Analytics 4 Tags

Use a Google Analytics 4 tag to measure your site in GA4: how many people visit, where they come from, which pages they view, how they move through your funnel, and how much revenue comes in. Unlike the advertising tags, GA4 is for site analytics, not for measuring or optimizing ads.

Nitoriq loads Google’s tag once, configures your measurement ID, and sends each event to that property. A typical setup is a page_view tag on every page plus one tag for each key action, such as purchase or generate_lead. GA4 shows no traffic until the page-view tag is published.

Nitoriq runs its own copy of Google’s tag, separate from any Google tag or Google Tag Manager already on your site. The two don’t interfere.

Preparation

Before you start

  • you have the web stream’s measurement ID from GA4 (G-…)
  • the container has triggers for page views and the actions you want to send
  • variables exist for values such as order ID, order value, and cart items
  • you know whether GA4’s enhanced measurement is tracking history-based page views (see the page views step)

Configure a Google Analytics 4 tag

Create the tag

Open the container, choose Tags, choose New Tag, then choose Google Analytics 4 under Analytics.

Enter the measurement ID

In GA4, open Admin, then Data streams, and choose your web stream. Copy the Measurement ID. To use different properties on different sites, store the ID in a variable and enter that variable, such as {{ga4_id}}.

Send page views

Choose the page_view event and select a DOM Ready trigger. On a single-page app, add a Route Change trigger too.

Leave Page Location, Page Title and Page Referrer empty. Nitoriq sends the current URL and title with each page view. After an in-app navigation, it sends the previous page view’s URL as the referrer. Fill them in only to override those values, for example to send URLs without query strings.

In GA4, open Admin, then Data streams, then your stream, then Enhanced measurement, and turn off Page changes based on browser history events. Otherwise GA4 sends its own page view on every in-app navigation, and each one is counted twice.

Send other events

Choose a recommended event, such as purchase, generate_lead or sign_up, or choose Custom event and enter a name. Names start with a letter, use only letters, numbers and underscores, and are at most 40 characters. GA4 reserves some names, such as page_view and session_start, so they can’t be used as custom names.

The form shows the parameters GA4 documents for the chosen event. For a purchase, that’s Value, Currency, Transaction ID, Items, Coupon, Shipping and Tax.

  • Value, Shipping and Tax are sent as numbers.
  • Currency: pick it from the list, or choose + to use a variable. GA4 needs it whenever Value is set, and drops the value without it.
  • Items should be a variable that holds GA4’s item list, for example from your data layer. It is sent as a list.

Put anything else under Event Parameters. The form names other parameters GA4 documents for the event. GA4 accepts up to 25 parameters per event.

Identify users (optional)

User ID takes your own ID for a signed-in user. Never use an email address or other personal data. User Properties takes up to 25 properties about the user, with values up to 36 characters. Both apply to this event and to every later event for the same measurement ID on the page. When a field you filled in is empty as the tag fires, for example after the user signs out, Nitoriq clears that value in GA4.

Select triggers, save, and publish

Choose the triggers, save the tag, and publish the container.

Google Analytics 4 fields

Measurement ID

The GA4 web stream to send to, or a single variable that holds it.

A value that isn't a valid measurement ID is refused on save; a variable is checked again when the tag fires.

Event

page_view, a GA4 recommended event, or a custom event.

Recommended events unlock GA4's standard reports.

Parameters and Event Parameters

The values sent with the event.

Values are sent with the types GA4 expects. Unusable values, and values longer than GA4 logs (100 characters for most parameters), are left out and noted in the debug overlay.

Fire once per page

Sends the event at most once per page load.

Stops a re-triggered event, such as a purchase on a re-rendered thank-you page, from being counted twice.

User ID and User Properties

Who the user is, set for this and every later event for the same measurement ID on the page.

GA4 doesn't accept a user ID as an event parameter, so Nitoriq never sends it as one.

Allow Google in a Content Security Policy

If your site sets a Content Security Policy, allow:

  • script-src: https://www.googletagmanager.com
  • connect-src: https://*.google-analytics.com and https://*.analytics.google.com

Check that it works

Open your page with ?niq_debug=1. The debug overlay lists each call, such as google · event purchase → G-…. In this mode Nitoriq also turns on GA4’s debug mode, so the events appear in GA4 under Admin, then DebugView.

Validation

A Google Analytics 4 tag is set up when

  • page views fire on DOM Ready, plus Route Change on single-page apps
  • GA4’s history-based page views are off if you use Route Change
  • ecommerce events send Value with Currency, and Items as a list
  • parameters of your own are registered as custom definitions in GA4
  • the container is published

Was this page helpful?