Published on September 17, 2017 | Posted in Wordpress
How to add author information from WordPress into Google Anayltics
Google Analytics is a valuable tool for any website it provide a great way to have insights in how users browse and discover your website. With a little bit of effort it possible to get more out Analytics in this guide we show how to add WordPress authors on blog post into Google Anayltics.
I’m going to make a couple of assumptions before we start the guide.
- You have a Google Analytics account and it’s currently on your site. Also using Universal Analytics
- You have a WordPress site and have the ability to update and make ammendments to templates
Adding the Author Dimension in Google Analytics
- Log into your GA Account
- Then Click on Admin, then under Property, go down to Custom Definitions and Click on Custom Dimensions.
- Click on New Custom Dimension
- Select the following values Name: Author, Scope: Hit and select Active. Then press create
- Copy the Javascript data
var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension1', dimensionValue);
Adding the code to WordPress
In wordpress there are multiple ways to build a theme and several methods to add this snippet. To keep this a quick and simple I’m going to add it directly to the template and be doing this on the Twenty Seventeen template. This method should work on most WordPress themes. Alternatively you can add it to the functions.php file.
?>
<script> ga('send', 'pageview',{'dimension1':<?php the_author_meta('display_name') ?>});</script>";
<?php
Viewing the data in GA
- You can either view the author information as a custom report or as a Secondary dimension. By going to the following report Behaviour, Site Content, All Pages
- Under secondary dimensions then type in Author.
This is quick guide to how to find out the author information in WordPress. Any questions or problems drop a comment below.