Sitecore Experience Analytics Google Chart

Why require your team to login to multiple systems just to review collected analytics?

This solution contains a SPEAK 2.0 component that allows for custom Google Analytic reports to be displayed within a dashboard page right in xAnalytics.

This is the exact source code as seen at the Sitecore Symposium 2016 talk ‘Experience the Singularity of Data’ and re-shown during a live webinar in October (get the full replay at https://www.paragon-inc.com/bringing_google_analytics_and_sitecore_together.)

You can download the source to play with along with Sitecore install packages from the GitHub repo https://github.com/gillissm/Paragon.Sitecore.ChartByGoogle.

What’s Included

  • TDS project for Sitecore artifacts
  • Two branches of code
    • MASTER – targets Sitecore 8.2 Initial Release, and is built using the new dependcy injection pattern
    • Sitecore_81 – targets Sitecore 8.1 update 3, and should work against any version that supports SPEAK UI 2.0
  • Sitecore package as found in _Documents folder
    • If you are running Sitecore 8.1 install the Sitecore package ‘Paragon.Sitecore.ChartByGoogle_8.1.zip’
    • If you are running Sitecore 8.2+ install the ‘Paragon Sitecore ChartByGoogle_82-1.zip’

GAInSitecore.png

How to Use

  1. Install the included Sitecore package or sync via TDS a. This only should be installed on a CM server!
  2. Login to Google Anayltics and create a service account, see https://developers.google.com/identity/protocols/OAuth2ServiceAccount
  3. Save the .JSON and .P12 files provided to the data folder on the CM server
  4. Update the following values in z.Paragon.GoogleAnalyticsChart.config a. JsonService with the file name of the .JSON b. P12Service with the file name of .P2 file c. AccountEmail wiht the email address supplied as part of the service account created
  5. The Google API assemblies have a dependicie on Newtonsoft.Json verision 7 so you must update your web.config with the following
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="7.0.0.0" />
      </dependentAssembly>
  1. Open Sitecore Expierience Analytics and you should find a new report page named ‘Google Anayltics’
  2. Add the new control as needed to new pages.
Advertisements

Third Party Analytics

After hearing stories from Sitecore users and developers about the struggles they dealt with trying to manage third party tracking IDs (such as those used by Google Analytics) between environments and sites, and experiencing the headaches in my own development the creation of this control was born.

These required third party tracking values usually are injected in one of two ways. The first method commonly used is to place the tracking code directly on the main layout. This is easy as it ensures the tracking code shows for all pages and only loads once. The downfall is as source code migrates through environments or additional the organization grows and additional sites are added into Sitecore the management of proper tracking IDs become a developer challenge to maintain.

The second commonly employed method is the usage of a configuration file. A component is developed or code is placed directly in the main layout that reads the required ID values and even possibly some form of JavaScript snippets that are injected at page load. This method is a step in the right direction, but still requires the development team to be fully aware of the correct IDs for the environment and site. [This use to be my preferred method until I woke-up realizing there was a better way, which now sits in-front of you.]

A simple content driven component that can be placed on pages as needed allowing the content team to take ownership and manage the tracking ids, keeping the right idea by environment and by sites.

What’s Included in the GitHub repo

  • TDS project for Sitecore artifact syncing
  • Full source code to allow for extension with other third party applications
  • Sitecore package as found in _Documents folder
    • If you are running Sitecore 7.2, 7.5, 8.0, or 8.1 install the Sitecore package ‘Paragon.Sitecore.ThirdPartyAnalytics_8.0.zip’
    • If you are running Sitecore 8.2+ install the ‘Paragon.Sitecore.ThirdPartyAnalytics_8.2.zip’

Get the code with packages from GitHub at https://github.com/gillissm/Paragon.Sitecore.ThirdPartyAnalytics.

thridpartyanalytics