I am trying to create a custom dimension that enables me to view the total amount of ad revenue earned by individual authors on my website and for that, I need a custom dimension(Author). I currently have this code but I'm not sure where to insert/modify it to retrieve author data.
var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension1', dimensionValue);
I'm insanely new to coding and tried following some tutorials but for some reason, the site isn't pulling the author's name. I've also set up google tag manager and everything but I find that I'm only stuck at the coding part. Should I add this code to the header of my site or do I need to modify the code above?
First, Locate the header.php of your theme in the source code (wp-content > themes > your theme). Next, copy and paste the following code after the opening head HTML tag ()
The code above initiates the dataLayer first and populates the information you need (in this case, the author on a blog post page). Next, Google Tag Manager is launched. The order is important, so do not change it. Note that you need to use your own GTM ID.
Second, you need to configure GTM to work with the information. Go to https://tagmanager.google.com and open your workspace.
On the left side, you'll see the main menu; click on the menu item Variables and click on the New button in the User-Defined Variables section.
Give the variable a name, choose the type Data Layer Variable, Name, and hit save to complete this step
Third, create another User-Defined variable to hold your Google Analytics tracking ID.
Fourth, create a new User-Defined variable to hold the Google Analytics Settings.
Make sure, the index corresponds with the index given in Google Analytics.
In Google Tag Manager, configure the tag as follows.
As you can see the info is being sent to GA: