Adding Analytics

HTML

How does it work?

Analytics can provide you with important and interesting information about how your website is being used. The information is collected by means of small snippets of code that are added to the web pages.

Such snippets enable data to be collected and reports generated. The data collected depends on the provider and the code snippet used. Example statistics include:

  • how many users visited your site over a period of time
  • how many pages were visited
  • search terms used to find your site
  • landing pages and exit pages.

Analytics Options

Adding Google Analytics to your site

If you haven't set up your Google Analytics account, visit http://www.google.ca/analytics/

Once your Google Analytics account has been set up, create a Tracking Code. This Tracking Code is a script that contains an identifier, which AEM requires.

<script type="text/javascript">
 
   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-18105214-1']);
   _gaq.push(['_trackPageview']);
   (function() {
	    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 	    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 	    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
   })();

</script>

The script above is an example of a Tracking Code. The part highlighted in blue - UA-18105214-1 - is the identifier. Find and copy the identifier in your Tracking Code.

After copying the identifier, sign into AEM and complete the following steps:

  1. Double-click your site's homepage to edit in the Editing Window.
  2. In the Sidekick, click on Page Properties...
  3. Click on the Advanced tab and expand the Google section.
  4. Insert the identifier into the Analytics ID field.
  5. If you are using Google's new Universal Analytics, check the Universal Analytics option.
  6. Click OK to save the changes. Your Google Analytics is now setup.

Note: In order to make all child pages inherit the analytics code, the Site Config page must be setup. However sub-sites will not inherit the analytics code.

Your site statistics will be viewable approximately 24 hours after set-up by logging into your analytics account.

Google Analytics registering unusual page views

Copying and pasting a URL from the authoring environment to the published site (typically for testing purposes) will result in Google Analytics registering a page view for that page. If you see a URL in your Google Analytics report with /content/sfu/, you can safely ignore these hits.

Using other analytics providers

Other analytics services will provide a similar script (a snippet of JavaScript) to place on your site. To use another provider's code, complete the following steps:

  1. Open your site's homepage in the Editing Window.
  2. Enter Inherited Content mode and insert a HTML Component into the top main content section.
  3. Click the EDIT button. The browser will open a new tab where you can paste the entire script, which should begin with "<script>" and end with "</script>". Click the SAVE button. 
  4. Close the tab to go back to the Editing Window.
  5. Exit the Inherited Content mode from the Sidekick. The HTML component will not be visible after this step, unless you re-enter Inherited Content mode. To make it easier to discover which page contains the script in the future, we recommend adding an annotation to the page. Make a note explaining the page contains a tracking script in the Inherited Content section.

The analytics is now setup. Check the support page of your analytics provider to learn how long it'll take to start collecting site statistics.