Create a GA account
- Go to Admin UI, click ACCOUNT dropdown, select 'Create new account
- Fill in account create form and click 'Get Tracking ID'
Create environment specify property
- Under PROPERTY section, select 'Create new property'
- Fill in New Property form. You can use App Name for specific environment, like Staging, Dev etc.
- Click 'Get Tracking ID' for specified environment
Sample code to track traffic:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].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-74922222-4', 'auto');
ga('send', 'pageview');
</script>
Create Custom Dimension
- In Admin UI, click 'Custom Definitions' under PROPERTY section
- Select 'Custom Dimensions', '+New Custom Dimension' button
- Give a name and specify scope, check active and hit 'Create'
- Follow the example codes to collect custom data
Sample code using javascript:
var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension1', dimensionValue);
View Result
- In Report UI, select Audience>Custom>User Defined
- From 'Secondary dimension' dropdown, select Custom Dimensions and your dimension name
- You should be able to see traffics group by each value of your custom dimension.
No comments:
Post a Comment