[UA] Measurement options for web pages

Learn about other ways to implement Google Analytics.

Web pages using gtag.js will have the latest web page reporting features in Google Analytics. If you would like to explore other methods for measuring web pages, there are several additional options to choose from.

In this article:

Measure usage with gtag.js

The Google tag (gtag.js) provides streamlined tagging across Google’s site measurement, conversion measurement, and remarketing products – giving you better control while making implementation easier. By using gtag.js, you will be able to benefit from the latest dynamic features and integrations as they become available. Learn more about getting started with Google Analytics.

Implement a Universal Analytics tag via Google Tag Manager

Use Google Tag Manager container to easily configure and deploy a Universal Analytics tag, or any supported 3rd party tags.

 

To set up a Universal Analytics tag via Tag Manager, follow these steps:

 
  1. If you haven't done so already, create a Tag Manager account.
  2. Install the Tag Manager container snippet in your website's code
  3. Configure a Tag Manager container.
  4. Create your Google Analytics tag in Tag Manager.
  5. Publish your Tag Manager container
 

Once your website has been configured with Tag Manager, you can add any additional tags from the Tag Manager interface with no need to re-deploy your website code.

Use analytics.js

The gtag.js library is the recommended tag for new implementations. However, there may be cases where you would prefer to use analytics.js (e.g., your site already makes use of analytics.js). See the developer documentation for more information.

Use the Measurement Protocol

The Google Analytics Measurement Protocol is a standard set of rules for collecting and sending hits from any Internet-connected device to Analytics. It's particularly useful when you want to send data to Analytics from a kiosk, a point of sale system, or anything that is not a website or web page. Because, while the Analytics JavaScript and mobile SDKs automatically build hits to send data to Analytics from websites and web pages, you must manually build data collection hits for other kinds of devices. The Measurement Protocol defines how to construct the hits and how to send them to Analytics.

Tips for dynamic websites

A dynamic website is one for which the web pages are generated using a programming language like Python, Ruby, or PHP. You can use an include statement or template to push the tag dynamically to each page:

  1. Find the JavaScript tag for your property, and then copy the entire tag. Don't make any changes to the snippet.

  2. Paste the entire snippet into its own include file, then add the include statement to your page header so that the snippet appears right after the opening <head> tag.

PHP includes
Copy the JavaScript tag snippet and add it to a file named analytics.php. Then include the analytics.php file on each PHP template page. For each template page, immediately after the opening <head> tag, add the following code:

<?php include_once("analytics.php") ?>

Was this helpful?

How can we improve it?
true
Choose your own learning path

Check out google.com/analytics/learn, a new resource to help you get the most out of Google Analytics 4. The new website includes videos, articles, and guided flows, and provides links to the Google Analytics Discord, Blog, YouTube channel, and GitHub repository.

Start learning today!

Search
Clear search
Close search
Google apps
Main menu
15299053106393690271
true
Search Help Center
true
true
true
true
true
69256
false
false