Search
Clear search
Close search
Google apps
Main menu

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:

  1. Sign in to your Analytics account.
  2. Select the Admin tab.
  3. Select an account from the drop-down menu in the ACCOUNT column.
  4. Select a property from the drop-down menu in the PROPERTY column.
  5. Under PROPERTY, click Tracking Info > Tracking Code.

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

    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.

    1. Once you have the Javascript tracking code snippet for your property, copy the snippet exactly without editing it.
    2. 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.

    If you wish to collect data from web pages to multiple properties at once, learn how to track a page using multiple accounts or properties.

  • Dynamic website

    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.

    1. Once you have the Javascript tracking code snippet for your property, copy the snippet exactly without editing it.
    2. 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.

  • Web-hosting service (you don’t manage source code)

    Web-hosting service (you don’t manage source code)

    Some Internet service providers or hosting platforms (such as Wordpress, GoDaddy, Wix, Weebly, etc.) simplify Analytics tracking code installation by offering plug-ins that automatically install it on your web pages. Review your platform’s instructions to add your Analytics tracking ID.

    Here are some Analytics implementation instructions for some common providers:

    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.

  • Website using Google Tag Manager

    Website using Google Tag Manager

    Google Tag Manager is a free tool to help add and manage multiple analytics and site tracking tags. To use Google Tag Manager to install your Analytics tracking code, visit the Google Tag Manager setup and installation article.

  • Mobile apps

    Mobile apps

    Read Analytics for mobile apps.

  • Internet-connected device

    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.

Read advanced resources for more details

The Google Developers site is a great resource to learn more about how the tracking code snippet works.

Was this article helpful?
How can we improve it?
Google Analytics training and support resources

Check out our comprehensive list to learn more about Analytics solutions.