Google Analytics is a very reliable way to get extensive website visitor information. To use this feature, you will need a Google Analytics account and then add the necessary tracking scripts to your website.
Applying for a Google Analytics Account
First, visit the Google Analytics website to apply for an account. You can use an existing Google account to get access to the Analytics dashboard. Next, you will need to add your website to your Google Analytics account.
Adding your site to the dashboard will require a verification process. This verification helps Google ensure that you own the website.
Obtaining Your Google Analytics Tracking Code
Once you’ve verified your website, you can then retrieve the tracking code:
- On your Google Analytics account, click the “Admin” link at the bottom left of the display.
- Select an account from the dropdown menu under the “Account” column
- Select a property from the dropdown menu under the “Property” column.
- Click “Tracking Info > Tracking Cookie” under “Property.”
The final step above will open a screen showing you the tracking code, called “Global Site Tag.”
Using the Google Analytics Tracking Code
Once you have your Google Analytics account set up and have added your website, you need to add the tracking code to the website to begin sending visitor data to Google. This step requires the use of a tracking ID, which is in your Google Analytics account.
There are several ways you can make use of the tracking code. For most conventional websites, this is typically done via the Google Tag Manager or by directly embedding the script within your website code.
Option 1. Google Tag Manager
Google Tag Manager offers an easy way to manage tracking code for multiple websites. Log in to your Google Tag Manager dashboard. Next;
- Click “Create Account” and furnish Google Tag Manager with the information requested.
- From the dashboard, click on the Container Name you just created.
- Click “Add New Tag,” then click the “Tag Configuration” work area.
- Select “Google Analytics: Universal Analytics” on the menu that appears.
- Select the track type you prefer (such as Pageview).
- Select the “Triggering” workspace and choose the events which will enable the tracking tag to work. In this case, the option should be “All Pages.”
Option 2. Embedding Script
How you embed the script will vary depending on the type of website operated.
For HTML Sites:
You can also choose to embed the Google Analytics script directly within your website HTML code. To do this:
- Copy the Google Site Tag script from your Google Analytics account
- You then need to paste the script in the code ( before the </head> tag) of every page on your website for which you wish to track visitor information.
For Dynamic Sites
Dynamic websites are those generated on user request by using scripts such as PHP. Adding the script on this type of site is more streamlined since you do not need to embed the entire script on every page – you can use an include function.
- Copy the script from your Google Analytics account.
- Create a file (e.g., MyGA-Tracking.php) and paste the script.
- Add the script to each template page after the <body> tag;
<?php include_once(“analyticstracking.php”) ?>
For Web Applications
Web applications such as WordPress and Joomla often offer modular features that support Google Analytics. You will generally seek a plugin or extension built for this purpose and install it in cases like this.
Once installed, you only need to provide the extension with your Google Analytics tracking ID, and it will handle the rest for you.