WP Global Site Tag

Description

WP Global Site Tag provides two related tools without mixing their state:

  • Tracking installs a Google tag or Google Tag Manager container on the public site.
  • Reporting connects an administrator to Google Analytics with read-only access and displays reports inside WordPress.

You can use either tool independently. Connecting Analytics never enables tracking or silently replaces an existing tag.

Free features

  • Guided Google Analytics connection and property and website data-stream selection.
  • Analytics overview, daily traffic trend, and top-five content reports.
  • An inclusive last-7-days range, with one dated trend point per day. Free rejects longer ranges on the server.
  • Persistent managed Google connection, plus an advanced self-managed OAuth option.
  • Plugin-managed, externally managed, or disabled tag installation modes.
  • GT-, G-, AW-, and DC- identifiers through gtag.js.
  • Official Google Tag Manager head and body snippets for GTM- identifiers.
  • Existing legacy UA- tracking IDs remain visible and continue rendering, including when Google routes the installed tag to a connected GA4 destination.
  • Multiple Google tag destinations and optional Consent Mode v2 denied defaults.
  • Backward compatibility for existing trusted custom gtag commands.

Settings are available under Settings > WP Global Site Tag. The Analytics dashboard tab contains the recommended connection route. The Tracking settings tab preserves the manual route.

Recommended Google connection

Click Connect with Google, choose an account, approve read-only Analytics access, and return to WordPress to choose a property and website data stream. The recommended connection uses the Digital Apps connection service so administrators do not need to create a Google Cloud project or handle OAuth credentials.

Digital Apps exchanges the authorization code and retains the Google refresh token while the connection is active. WordPress stores an encrypted opaque connection token and short-lived Google access tokens. The plugin then calls the Google Analytics Admin and Data APIs directly, so Analytics property, stream, and report requests and responses do not pass through Digital Apps.

Because Digital Apps retains the refresh token, it is technically able to request Analytics access while the connection remains active. The advanced self-managed route below is available for administrators who do not accept that trust boundary.

Administrators who require no Digital Apps token custody can open Advanced: use your own Google OAuth application. That route provides the Google Cloud instructions and exact callback URL. Credentials may be saved encrypted or defined in wp-config.php as WP_GLOBAL_SITE_TAG_GOOGLE_CLIENT_ID and WP_GLOBAL_SITE_TAG_GOOGLE_CLIENT_SECRET. Constants take precedence.

After Google returns to WordPress, choose an Analytics property and its website data stream. The plugin recommends hostname and exact existing-Measurement-ID matches, but an administrator confirms every selection.

Identifier guide

  • Property ID is the numeric GA4 reporting property used by the Data API.
  • Data Stream ID is the numeric identifier of one stream inside a property.
  • Measurement ID begins with G- and identifies the website tag for that stream.
  • Google Tag Manager container ID begins with GTM- and is a separate tracking integration.
  • A legacy Universal Analytics tracking ID begins with UA-. Version 2 preserves it as the frontend tag but does not use it as the GA4 reporting Measurement ID.

These values are stored separately. Choosing a reporting stream does not overwrite the generic tracking ID unless the administrator explicitly chooses replacement after a mismatch warning.

Installation modes

  • Install with WP Global Site Tag lets this plugin output the saved tag.
  • Tracking is installed elsewhere keeps reporting available but prevents duplicate tag output.
  • Do not install a tag disables tag output while preserving the reporting connection.

Existing users

Version 2 preserves the existing option name, manual tag ID, additional destinations, Consent Mode setting, trusted custom commands, hooks, and frontend behavior. This includes legacy UA- identifiers that Google may route to a connected GA4 destination. Existing sites default to plugin-managed installation so an update does not stop measurement. Analytics reporting remains disconnected until an administrator completes the new read-only connection.

Consent and privacy

Consent Mode is not a consent banner. You still need a consent management platform or your own consent interface to collect a visitor’s choice and update Google’s consent state.

When Consent Mode defaults are enabled, this plugin still loads gtag.js. Google may receive consent-state and cookieless requests before consent is granted. If your requirements prohibit loading Google before consent, use the wp_global_site_tag_should_render filter to prevent output until your consent system allows it.

When using a GTM container, configure consent initialization and defaults inside Google Tag Manager. The plugin’s Consent Mode setting applies only to gtag.js output.

With the recommended connection, Digital Apps stores the Google refresh token and WordPress stores an opaque connection token and short-lived access tokens. With the advanced self-managed connection, OAuth credentials and Google refresh and access tokens stay on WordPress. Locally stored connection data is encrypted with keys derived from WordPress salts and saved in non-autoloaded options. Administrators can disconnect at any time, which requests revocation and removes local connection data and report caches. The saved frontend tag remains unchanged.

External services

When tracking is enabled, visitors’ browsers request Google tag resources from https://www.googletagmanager.com. These requests disclose standard web request information such as the visitor’s IP address, browser details, and referring page to Google. Configured Google products may send additional measurement or advertising events.

The recommended connection sends the site URL, hostname, plugin and protocol versions, callback URL, a short-lived state and code challenge, and later an opaque connection token to https://connect.digitalapps.com/v1/. Digital Apps uses this information only to complete Google authorization, retain the refresh token, renew short-lived access, and revoke the connection. It does not receive Analytics property, stream, or report requests or responses.

When an administrator views reports, the plugin communicates directly with these Google services:

  • Google authorization at accounts.google.com.
  • Google Analytics Admin API at analyticsadmin.googleapis.com.
  • Google Analytics Data API at analyticsdata.googleapis.com.

The advanced self-managed route additionally communicates directly with Google token and revocation services at oauth2.googleapis.com.

The plugin requests the analytics.readonly scope. Google receives the administrator’s authorization request and normal request metadata. Reporting requests include the selected property, date range, and allowlisted report fields. The plugin does not add telemetry. Review the Digital Apps Privacy Policy and Terms.

Review Google’s Privacy Policy, Terms of Service, OAuth terms, and Google Analytics terms.

Screenshots

Installation

  1. Upload the wp-global-site-tag folder to /wp-content/plugins/, or install the plugin through WordPress.
  2. Activate WP Global Site Tag.
  3. Open Settings > WP Global Site Tag.
  4. For reports, click Connect with Google, choose an account, property, and website data stream.
  5. For manual tracking only, open Tracking settings, enter a valid tag or container ID, choose the installation mode, and save.
  6. Verify public tag behavior with Google’s Tag Assistant and verify your consent workflow.

FAQ

Can I keep my existing manually configured tag?

Yes. Version 2 preserves it. The Analytics setup looks for an exact stream Measurement ID match and asks before making any change. If the saved value is a legacy UA- identifier, confirm current collection in GA4 Realtime before replacing or removing it.

Why do reports need a Google connection when tracking already works?

Tracking sends data from the public site. Reporting requires separate read-only permission to retrieve data from a GA4 property. A manual tag alone does not grant report access.

Do I need to create a Google Cloud OAuth application?

No for the recommended connection. Digital Apps owns the OAuth application and required API configuration. Create your own application only when using the advanced self-managed route.

How do I fix redirect_uri_mismatch with my own OAuth application?

Open the advanced connection section, copy its callback URL, and add that exact value to your OAuth client’s authorized redirect URIs. Check scheme, host, path, and trailing slash exactly.

What happens when Google access is revoked?

The dashboard asks an administrator to reconnect. Tracking remains in its selected installation mode and the saved tag is not removed.

Why is a property or stream missing?

Confirm the connected Google account can access the GA4 property, both required APIs are enabled, and the property has a Web data stream. Mobile-app streams are not offered as website choices.

Why is cached data shown?

During a temporary Google outage or rate limit, the dashboard may show its most recent cached report with a clear stale-data notice. Use Refresh after Google is available again.

Can Free show more than 7 days?

No. Free provides an inclusive 7-day report. The separately installed Pro add-on adds 30-day, longer, and custom ranges.

Does enabling Consent Mode block Google until consent?

No. It queues denied defaults before Google tag configuration, but gtag.js is still requested. Connect a consent management platform that calls gtag('consent', 'update', ...), or prevent rendering with the provided filter until loading is allowed.

How do I prevent tag output for selected requests?

Choose an external or disabled installation mode, or return false from the wp_global_site_tag_should_render filter. The filter receives the current decision, normalized identifier, and normalized plugin options.

What does uninstall remove?

Uninstall removes plugin settings, encrypted Google credentials and tokens, OAuth state, and registered report caches, including across multisite. Define WP_GLOBAL_SITE_TAG_PRESERVE_DATA as true before uninstalling to retain data.

Reviews

23 listopada 2018
This is my first plugin review and it fully deserves the 5 stars – why? It’s extremely simple to use, not bloated, does not spy on your data and it does exactly what it promises – you just add your UA code for Google Analytics and then in advanced configuration your Global site tag, on your „Thank you” page you manually add the „Event snippet” and there your go – you’re all set! Look no further – this is the plugin for Analytics and Conversions tracking your were looking for.
2 marca 2018
Super easy to install and setup. A small suggestion would be to add the Settings hyperlink on the plugin in the Wordpress plugins list, rather than trying to locate the new Plugin menu on the left sidebar in Wordpress.
Read all 3 reviews

Contributors & Developers

“WP Global Site Tag” is open source software. The following people have contributed to this plugin.

Contributors

Translate “WP Global Site Tag” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

2.0.0

  • Added a persistent Connect with Google flow, advanced self-managed OAuth, property selection, and website data-stream setup.
  • Added Free overview, trend, and top-content reports for an inclusive 7-day range.
  • Added encrypted local connection storage, optional self-managed credentials, safe token refresh and revocation, fixed-host Google API adapters, caching, stale fallback, and refresh controls.
  • Added explicit plugin-managed, externally managed, and disabled installation modes without changing existing tracking on upgrade.
  • Preserved legacy UA- tracking IDs during upgrades and added guidance for connected GA4 destinations.
  • Added centralized entitlements and extension points for the separate Pro add-on.
  • Added responsive, keyboard-accessible setup and dashboard interfaces with live status announcements.
  • Expanded privacy, external-service, troubleshooting, uninstall, developer, test, and release documentation.

1.1.0

  • Added correct, separate rendering for Google tags and GTM containers.
  • Added structured multiple destinations and Consent Mode v2 defaults.
  • Restricted custom JavaScript editing to trusted users and blocked script-tag breakout content.
  • Fixed missing-option warnings, incomplete saves, duplicate configuration, escaping, accessibility, and translation issues.
  • Added complete uninstall cleanup, including multisite support and an opt-out constant.
  • Replaced legacy Docker, Gulp, and Webpack tooling with wp-env and smoke tests.

1.0.7

  • Removed warning messages.

1.0.6

  • Added MIME type metadata.

1.0.5

  • Updated the settings label.

1.0.3

  • Added a settings link on the Plugins screen.
  • Moved the settings page under Settings.

1.0.2

  • Updated compatibility metadata for WordPress 5.0.

1.0.0

  • Initial release.