We often work on media sites that have several authors, and the one essential statistic they all want to be able to track is author performance. Example sites we’ve worked on that have that need include:
The standard configuration of Google Analytics doesn’t have author tracking. However, they do allow customization of the data they track via custom dimensions.
To track authors, we need to add a custom dimension to Google Analytics. We’ll also need to update the Google Analytics script embedded in our site to capture author information.
If this all sounds a little daunting and technical, don’t worry. Just follow these instructions below.
Step 1: Login To Your Google Analytics Account
Login to your Google Analytics account and select the “Admin” area in the top navigation.
Once inside the Admin, you’ll see three sections. In the first section on the left, select the Account on which you want to work.
In the middle section, select the specific Property (website) you want to work on and open “Custom Definitions.”
When you open Custom Definitions, a sub-menu will appear. Select “Custom Dimensions” from the sub-menu.
Step 2: Create A Custom Dimension For Authors
Next, you’ll create a “Custom Dimension” by clicking on the big red “New Custom Dimension” button.
Name the new Custom Dimension “Author.” Leave the “Scope” dropdown as “Hit,” and also leave the “Active” box checked.
Save the Custom Dimension by clicking “Create.”
Step 3: Update Your Google Analytics Code
Hint: Pay close attention here. This part gets a little hairy if you’re not technically inclined.
Once the you have created the Custom Dimension, it’s time to update your Google Analytics code to capture the author name for tracking.
If you use the Genesis Framework, you may have embedded your Google Analytics code in the Genesis theme settings, in the “Header and Footer Scripts” area. Since we need to pass dynamic information to Google Analytics, we’ll have to move the script into our theme files.
Note : No matter where you code is currently embedded , be sure to remove it so you don’t load the script twice and inflate your metrics.
Even if you’re not using Genesis, just follow along. Everything below will still apply.
Copy your Google Analytics code, and drop it into a new file in your favorite text editor.
We’re going to change your Google Analytics Code to look like this:
Note: In this example, we’re using Universal Analytics. If your site is on the old Google Analytics, we recommend switching to Universal Analytics first. Also note, we’ve removed the <script></script> tags at the start and finish of the script. Save the file as google.js and upload that file to your current theme /js directory via FTP. If you don’t have a “js” subdirectory in your current theme, create one and upload the file there. Next, in your functions.php file add the following PHP code:
The reason we’re putting the code in different files is so that we can pass the php variable with the author name to Google Analytics and still enqueue our javascript for security.
Once you’ve completed Step 3 and saved your files, go to Google Analytics and make sure you’re still getting data by clicking on “Real Time” in the side navigation.
If no one is on your site right now, open your site homepage in a different browser. Using a different browser will ensure you’re not logged into WordPress which may cause Google Analytics not to track you, depending on how you have things set up.
Step 4: View Author Stats in Google Analytics
Now that we have everything set up, it’s time to start seeing how our authors are performing.
We can view the author statistics in several of the Google Analytics views. For the sake of illustration, I’m going to look at the most popular pages on the site and see who the authors of those pages are.
In Google Analytics navigate to Behavior > Site Content > All Pages.
In the window on the right, there is a drop down for “Secondary Dimension.”
Under that dropdown open “Custom Dimensions” and select “Author.”
This will add the author column to the report you are looking at.
From here you can sort, search, and view the information in any number of ways. You can also export the data from Google Analytics for further analysis in a spreadsheet.
Or…
We can set up a custom report in Google Analytics to automate some of the work.
Setting Up A Custom Report In Google Analytics
To create a custom report in Google Analytics, navigate to “Customization” in the main navigation and select “New Custom Report” under “Custom Reports.”
We now have a new custom report window to define the report.
- Name the overall report (you can have several related tabs in a report). For this report, I’ve chosen to call it “Author Stats.”
- Next, under “Report Content” name the individual tab. I’ve chosen to call this one “Top Authors by Pageview.”
- Select Type: “Flat Table.”
- In “Dimensions”
- Slot 1 “add dimension“: Select “Author” from “Custom Dimensions“
- Slot 2 “add dimension“: Select “Page Title” from “Behavior”
- In “Metrics” select “Pageviews” from “Users.”
- Leave everything else as it is and click “Save.”
Hint: When choosing a dimension, you’ll see a search box when you click “add dimension.” You can start typing the name of the dimension you want rather than clicking through everything.
You can now view your custom report with top pages and their associated authors for quick reference!
Frequently Asked Questions:
1. Why do I need to add my code to different files and enqueue the scripts?
The main reason is for security purposes. It is always a good idea to enqueue javascript files for use in WordPress to prevent hackers from exploiting them. This situation has added complexity because we want to pass a php variable (author name) into javascript so that it can be passed to Google Analytics. Since we want to enqueue our scripts for security, breaking things up was the most logical way to handle it.
Though, if you have other suggestions, feel free to leave them in the comments below.
2. How do I view authors by total page views?
In short, you’ll add another tab to your custom report that is exactly the same as the first tab we created but without the “Page Title” dimension.
3. How long will it take before I see author data?
It may take up to 24hrs before you start seeing author data in Google Analytics.