In one of intranet project, we used Google Analytics to generate the usage reports; requirement is to capture the UserNames and User Region information in the analytics reports.
Setting up Google Analytics is very easy, we need to add the GA script in hidden CEWP. For more information follow below article:
Basic Google Analytic script captures page visits, time on each page, and few other attributes. But as per requirement, we need to capture:
1. Logged in UserName
2. User Region – Region is a custom property is SP user profile.
Once the above information is available, set them to Google Tracking account as custom variables.
Now we have the required information, we need to pass this to Google Analytics site as custom variables.
_gaq.push(['_setCustomVar', 1, // This custom var is set to slot #1. 'Items Removed', // The name acts as a kind of category for the user activity. 'Yes', // This value of the custom variable. 2 // Sets the scope to session-level. Optional parameter. ]); _gaq.push(['_trackEvent', 'Shopping', // category of activity 'Item Removal', // Action ]);
Note: after setting custom variables, it will take at least 24hrs to crawl the content. You will not see these variables immediately.
Now finally, using the Google Analytics reports option, create your own reports for crawled content.