duane blake

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.

How to add author information from WordPress 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

  1. Log into your GA Account
  2. Then Click on Admin, then under Property, go down to Custom Definitions and Click on Custom Dimensions.
    How to find custom definition in GA
  3. Click on New Custom Dimension
  4. Select the following values Name: Author, Scope: Hit and select Active. Then press create
    Create Author in WordPress Custom Post Type
  5. 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

  1. 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
    All Pages in GA
  2. Under secondary dimensions then type in Author.
    Custom Dimenson in GA

This is quick guide to how to find out the author information in WordPress. Any questions or problems drop a comment below.

Leave a comment

Your email address will not be published. Required fields are marked *