Track WordPress Author Stats: Implement Custom Dimension in GA using GTM

It is always a good idea to track the statistics of different authors on a blog to optimize the revenue of a blog and appreciate one’s contribution. In this scenario, I am going to only talk about WordPress blogs and how to track the stats of different authors on a WordPress blog.

These stats could be anything from page views to the bounce rate to any other stuff that you would like to track. To track the stats, we would be using Google Analytics custom dimension feature and then integrate that with Google Tag Manager (GTM).

How to track WordPress Author Statistics and its complete implementation

Before we proceed further, here are the prerequisites:

So, let’s start –

 1. Create a custom dimension in your Google Analytics account

Go to Google Analytics Admin -> Property Settings -> Custom Definitions -> Custom Dimensions

1. Create a Custom Dimensions under Custom Definitions in GA

 2. Create a new custom dimension

Name the custom dimension as per your convenience, note down the index number and select the scope as a hit.

2. New Custom Dimensions of Author

 3. Create a new Data Layer Variable for the Authors

One of the main reasons why I asked you to install the DuracellTomi’s Google Tag Manager for WordPress because it automatically creates the data layer variable of some of the common WordPress post elements such as post type, authors, category etc. So, in this case, we do not need to do anything just install the plugin and put the GTM code through this plugin.

But before we proceed further, let us understand the logic first based on what DuracellTomi’s Google Tag Manager for WordPress plugin does or you can do a simple skip to step 4 as well.

  • It loads the data layer with the current value of a single post attribute such as post type, post category, author etc each time a single post loads.
  • We are going to leverage this property of this plugin to create two data layer variable. One will be the author and another will be post type.
  • We will create a trigger which will fire only on the pages where the post type is a post, not pages. This condition of firing the trigger on posts only will be met when the post type will only post and that is being achieved through creating data layer variable of post type
  • Here is how the data layer looks like when I preview

11. GTM Preview

This plugin replaces the value of the author, category etc each time a post loads. We will be picking up the data from there on every new hit on all the blogs and pushing into Google analytics.

4. Create a new Data layer variable for the Authors

Go to Variables in GTM -> New under User-Defined Variables. Name the variable as per your choice but I prefix dlv in front of all the data layer variables

3. Create new data layer variable for authors

Choose the variable type as Data Layer Variable

4. Choose data layer variable as the variable type

Define the Data layer variable name (as we saw previously in step 3) as in the GTM preview. If you are using that plugin, it would be pagePostAuthor

5. Put PagePostAuthor as dlv for Author in wordpress

5. Create another Data layer variable for the post type

This data layer variable will help fire the trigger only on the posts where the post type matches single post in the WordPress. Follow the same step as step 4 to create the data layer variable for the post type.

6. creating new data layer variable for post type

You can name the variable per the convention as dlv-pagePostType and put in the data layer variable name as pagePostType as shown in the picture above.

6. Create a trigger to fire only on the posts

Go to triggers -> Click new -> Name your trigger -> Click on trigger configuration to begin the setup

7. Create a new trigger for Authors

Choose page views as the trigger type

8. Select the trigger type as page view

Fire this trigger only when the posts are viewed on your blog.  So, you the data layer variable created earlier to define the firing event condition of the trigger as follows

9. pagePostType Trigger

7. Create a new tag for tracking the authors in GA

  • Create a new tag with track type as a Page view
  • Enable overriding section in the tag
  • Under the more settings, open custom dimensions.
  • In the index, fill in the index number from Google Analytics and Dimension value as the data layer variable name as follow

10. Firing the tag for the Author tracking in WordPress

Now you can preview to see if the trigger is being fired on the correct pages and correct data layer information are being fetched. Once, it’s done. Submit and publish the tag.

8. Check in Google Analytics for the Authors data now

  • Go to -> Audience -> custom -> user defined
  • Under secondary dimensions drop down, select authors and you will see the names of the authors as follow

12. Authors being tracked in Google Analytics

And you are done.

Authors metrics to be analyzed in Google Analytics:

Here are some of the author’s metrics that you can utilize in the Google Analytics for blog improvement

  • bounce rate
  • pages/ session
  • revenue from the author
  • most viewed post etc.

Once you have the data, you can further use it to improve the user engagement and quality of the blog by the author. Besides, you can also track other things such as post category or post type etc. using the same method as done in this blog post.

Other than that, if you think we missed something or there is further improvement that can be made to this blog post, please share your thoughts in the comments below

Have a Question? Get in Touch!

Leave a Reply

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