Website administrators want to know who, when, how, and what users do on their websites. Google Analytics can provide that information if the proper tracking code is found on the web pages.
There is more than 1 way to insert the tracking code, including using the Google Tag Manager or the WordPress plugin MonsterInsights. This post details a manual method of directly embedding the tracking code in a WordPress theme, assuming that you have already set up a Google Analytics account for the target website. In addition, I assume that you have created and activated a child theme for your website. If you are hosting multiple websites within the same WordPress instance, I assume you have a separate child theme for each site.
- Login to Google Analytics, and select the account corresponding to the target website.
- Click Admin on the LHS menu bar.
- Click Tracking Info and then Tracking Code in the middle column.
- Copy the Global Site Tag script to be pasted next in the WordPress theme.
- SSH into web host, and copy the header.php file from the parent theme to the children theme.
- Paste the tracking code script.
The script should be inserted in the header.php file in your child theme directory, say /var/www/example1.com/wp-content/themes/twentyseventeen-child, just before the call to wp_head() at the end of the header specification. - Navigate back to Tracking Info/Tracking Code on Google Analytics and click Send Test Traffic.
A new session of your website pops up in the browser. - Navigate to Reports section on the LHS menu bar, click Realtime, then Overview.
You should see the just opened session being counted in the number of active users on site.
$ cp /var/www/example1.com/wp-content/themes/twentyseventeen/header.php /var/www/example1.com/wp-content/themes/twentyseventeen-child/header.php
1 comment:
This Great Post! But if you move from blogger to WordPress then use XAMPP Local system.
Post a Comment