Set up Analytics tracking

Find your tracking ID or tracking code snippet

To set up Google Analytics tracking, you’ll usually need either your Analytics tracking ID or the entire Javascript tracking code snippet. This corresponds to your Analytics property. To find the tracking ID and code snippet:

Choose how to set up tracking

There are several ways to collect data in Analytics, depending on whether you want to track a website, an app, or other Internet-connected device. Select the best installation method for what you wish to track.

Static website

A static website is one in which the page HTML is NOT generated using a programming language or interface such Python, Ruby, PHP, etc. To collect data, you must copy and paste the Analytics tracking code into the source code on every web page you wish to track.

Once you have the Javascript tracking code snippet for your property, copy the snippet exactly without editing it.

Paste your tracking code snippet (unaltered, in its entirety) before the closing </head> tag on every web page on your site you wish to track.

Dynamic website

A dynamic website is one in which the HTML is generated using a programming language such as Python, Ruby, PHP, etc. To collect data, you must include the Analytics tracking code in the source code on every web page you wish to track. You can use a common include or template to push the tracking code dynamically into every page.

Once you have the Javascript tracking code snippet for your property, copy the snippet exactly without editing it.

Paste your tracking code snippet into its own include file, then include it in your page header, so that the snippet appears before the closing </head> tag on every web page on your site you wish to track.

Using PHP?

Copy the Javascript tracking code snippet and add it to a file named analyticstracking.php. Then include the analyticstracking.php file on each PHP template page. For each template page, immediately after the opening <body> tag, add the following code:

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

Note that you can update the tracking code for dynamic websites more efficiently using Google Tag Manager.

Please note that when you use a plug-in to collect data, you may not have the option of adding configuration settings to customize the data you wish to track. If you have special requirements for tracking data, review how to get started with Analytics.

Mobile apps

Internet-connected device

To collect data from an Internet-connected device such as online point-of-sales system, video game console, customer relationship management system, or other platform, you must use the Analytics Measurement Protocol.

Verify the tracking code is working

Once you have successfully installed Analytics tracking, it may take up to 24 hours for data such as traffic referral information, user characteristics, and browsing information to appear in your reports. However, you can check your web tracking code setup immediately.