Google Analytics is a web analytics solution from Google and mostly free service that tracks the visitor’s reach on the website. Google acquired this service from Urchin in 2005. As webmaster and owner of the WordPress site, one always wish to include Google Analytics, for proper measurement of visitor’s metrics. In order to add Google Analytics to WordPress website without the plugin, we need three segments.
- The first segment is all about creating a Google Analytics account.
- The second segment is to find out the Google Analytics tracking code for your website.
- The third segment is to add Google Analytics tracking code into the WordPress website through cpanel.
1.Create a Google Analytics account for your WordPress website:
- Open the Google Analytics website. [https]://[www.google.com]/[analytics]/
- Use Google mail to log in to it.
- Go to ADMIN inside Google Analytics.
- You can open 100 accounts for sites inside Google Analytics.
- Go to CREATE ACCOUNT.
- Click on CREATE ACCOUNT.
- Select WHAT YOU WOULD LIKE TO TRACK?
- You may choose from WEBSITE or MOBILE APP.
- Here we are opening the account for the website so should choose WEBSITE.
- In the ACCOUNTS NAME name, you’re my new account name.
- In the SETTING UP YOUR PROPERTY the first part is WEBSITE NAME.
- Write the name of your website there.
- In the WEBSITE URL write the complete website URL.
- In the INDUSTRY CATEGORY select one from which your website belongs to.
- Then in the REPORTING TIME ZONE, first select your country and then provide country-specific time zone.
- Then comes DATA SHARING SETTINGS.
- There some subset of it and you can select or not select as per your wish.
- Those are GOOGLE PRODUCT & SERVICES, BENCHMARKING, TECHNICAL SUPPORT, ACCOUNT SPECIALISTS.
- Then click on GET TRACKING ID to create Google Analytics Account for your website.
2. How to find the Google Analytics Tracking Code for Website:
- Now, you opened Google Analytics for your website.
- Log in to Google Analytics.
- Go to SETTINGS.
- Go to ADMIN.
- Here you will find out three columns.
- One is ACCOUNT, then PROPERTY and then VIEW.
- Go to middle one namely, PROPERTY.
- Then go to TRACKING INFO. Click on it.
- Then click on TRACKING CODE. Click on it.
- Here, you will find TRACKING ID beginning with UA- and then STATUS.
- Then WEBSITE TRACKING you will find GLOBAL SITE TAG (gtag.js).
- Copy that GLOBAL SITE TAG code entirely.
- Keep it in safer place as in the next phase we will be pasting this in header.php of the active theme file.
3. How to add Google Analytics tracking code to the website:
- Log in to cPanel.
- Put USERNAME and PASSWORD.
- Go to FILES and then FILE MANAGER. Click on it.
- Go to WP-CONTENT.
- Then THEMES and then choose ACTIVATE THEME.
- First back up HEADER.PHP file to your local computer.
- Then choose HEADER.PHP and EDIT and then click on EDIT again.
- I am using the twentytwelve child theme.
- It is better to use a child theme while performing any modification to file.
- Search for </head> and just before it copies paste the entire code collected from Google Analytics tracking code in the earlier segment.
- Then click on SAVE CHANGES to apply Google Analytics tracking code to your website.
- When you edit the file through cPanel which is a secure method but still back up the same file to the computer for extra security.
- Always use the Child Theme, for your website. It keeps the main theme secure and whenever anything goes wrong then you can revert to the original theme again.
- How to Add Pagination to TwentyTwelve Theme of Your WordPress Blog without a Plugin?
- How to add copyright in footer of wordpress without plugins?