Measurement options for web pages
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:
Track using gtag.js
The Global Site Tag provides streamlined tagging across Google’s site measurement, conversion tracking, 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:
- If you haven't done so already, create a Tag Manager account.
- Install the Tag Manager container snippet in your website's code
- Configure a Tag Manager container.
- Create your Google Analytics tag in Tag Manager.
- Publish your Tag Manager container
Once your website has been configured with Tag Manager, you can add any additional tracking tags from the Tag Manager interface with no need to redeploy your website code.
The gtag.js library is the recommended tracking code 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
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 tracking code dynamically to each page:
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
<body> tag, add the following code:
<?php include_once("analyticstracking.php") ?>