How to setup Google Analytics tracking custom dimensions
To track a custom dimension for each of your pageviews, you first need to setup the custom dimension in the Google Analytics admin console and save the index number so that you can add it to your tracking script.
First, go to the Google Analytics admin menu. Then choose Custom Definitions > Custom Dimensions.
https://gyazo.com/ab8fe15f75c81db8b7b3117a5d12bf2d
Create a new custom dimension and name it “Author”.
https://gyazo.com/e09346b9cd01bc9e695a9de73c10f565
Now you need the code snippet to send dimension values, which contains the numeric index that associates your data with the correct custom dimension in Google Analytics. In our case, “Author” is dimension1.
code:code
var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension1', dimensionValue);
Once you have the custom dimension setup in Google Analytics, it is time to add it to your tracking script. Here is what a default tracking script looks like in Universal Analytics. Obviously each property needs to set it’s own property ID.
What we need to do is to add our new custom dimension tracking snippet before we call ga('send', 'pageview').
On our site, we use a PHP function to add the Google Analytics tracking code to the wp_head hook in WordPress, like so.
code:code
//Google Universal Analytics
function google_analytics() { ?>
<script>
(ir.q=ir.q||[]).push(arguments)},ir.l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)0;a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-103563291-1', 'auto');
ga('send', 'pageview', {'dimension1':'<?php the_author(); ?>'});
</script>
<?php }
add_action ('wp_head', 'google_analytics');;
Come to your Wordpress site > choose Apperance tab > Editor > theme function.
In tab Child Theme functions (Functions.php), copy the above code and paste there. Don't forget to add YOUR ANALYTICS PROPERTY ID to the code.
https://gyazo.com/e2c0d02cd82ef2d3718f12c52e75af4a
To view these new statistics, you can add a secondary dimension when your are on a pageview or other report, using the secondary dimension drop-down.
Come to Google Analytics, choose tab Behavior > Site content > All pages > Secondary dimension > Custom Dimension > Author
https://gyazo.com/0184732449378a514607d6743b03d6cc
The resulting report will now show author names for your posts.
https://gyazo.com/e520135bc55d37f7e233bd443e92a361
next access to your spreadsheets choose Add-ons > Google Analyst > create report if you just want update your website data choose schedule reports
https://gyazo.com/399ec1ebf4aff13e09e1be99c18554e3
if you want to add new website Add-ons > Google Analyst > create new report
https://gyazo.com/219e8f3acc359de6f91e0ab195519b1b
https://gyazo.com/3989f239a28886efe60b259b1245f2ae
1) Name your report: name your website you want to add
2) Select a view:
Account : BSC project
Property: Choose name the website you want to add
3) Choose configuration options
Metrics : ga:pageviews
Dimensions: ga:pageTitle ga:dimension1
Next choose Create report . After that you need to choose Author report
https://gyazo.com/2aac624dd869472e9ec5080f24be522a
Next you need to fill Name the website, Author , Posts, Pageview and use syntax like this :
https://gyazo.com/8585fe7238e4252b04d857d2b14c9dca
It will update automatically. Done