To Our Amazing Educators Everywhere,
Happy Teacher Appreciation Week!
Google Analytics is a great way to gather data and understand how visitors to your Canvas instance are navigating their courses. If you are new to Google Analytics I would recommend reading How to Set Up Google Analytics for Canvas by @jperkins or going through this Google Analytics Course for Beginners from Google. This document will share how to manage Google Analytics using Google Tag Manager and discuss some of the benefits for doing so.
A tag is simply a snippet of code that you place on your website, generally to facilitate communication with another website or service. When you add Google Analytics JavaScript to Canvas you are adding a tag to share data from your instance of Canvas with Google. The Google Tag Manager (GTM) tool provides a number of helpful tools to manage Google Analytics or any other tags that you may want to add to your site.
Although Google Tag Manager does require some time to become familiar with another tool, the benefits are tremendous:
The article How to Set Up Google Analytics for Canvas is still a great place to start to setup a Google Analytics account and create your custom dimensions before we get started with GTM. If you are the kind of person who likes to look before you leap, here are some resources to get started with:
The first step will be creating a Google Tag Manager container that it will use to insert tags (i.e. Google Analytics) when you publish them. Here is how you can get started:
// GOOGLE TAG MANAGER CODE
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');
var googleTagManager = '<!-- Google Tag Manager (noscript) -->' +
'<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>' +
'<!-- End Google Tag Manager (noscript) -->';
$('body').prepend(googleTagManager);
So both of those snippets can be added together to your custom JavaScript file and they will start showing up in the appropriate place on your pages. Be sure to replace GTM-XXXXXXX with your unique code.
Now that you have a container setup, we will go through the process of adding Google Analytics to that container.
Even though you have added your Google Analytics code to the container, it will not go live on your site until you publish it. This is an area where Google Tag Manager shines. Before you publish, take a moment to try out the Preview feature to make sure the code is working correctly:
If you enter Preview mode in Chrome, then you can visit your Canvas Instance and a dialog will show up on the bottom of your browser where you can check to make sure your tags are working correctly. With Preview mode enabled you can also go into Google Analytics to verify that data is being received from your visits.
One you have verified that it is working correctly, click "Submit" and you will be prompted to enter information about this version of the tag that you are publishing:
Enter whatever information you would like and click "Publish". Google Analytics has now been published to your instance of Canvas and you should start to see the data rolling in!
Check back soon for a follow up blog post on adding custom dimensions through Google Tag Manager.
I'm looking into adding GTM to our Canvas instance as we have been using Google Analytics for about four months now. Are there any GTM recipes/tags that have been especially beneficial with Canvas?
Good question @simsrg , now that we have GTM installed we are playing with a few things. Today I was able to start tracking file downloads across all of courses which we will be helpful. Next I'm going to work on YouTube tracking. Other ideas we're considering:
The nice thing about GTM is that it makes it pretty easy to track these kinds of things. I hope to get up a post in the next couple of weeks with some of our recipes.
Thanks @christopher_phi for the suggestions! I'm looking forward to seeing those recipes.
I've been running Google Analytics (GA) since June at our institution and it has been great. Looking ahead to adding Google Tag Manager (GTM) to the mix does this bullet list below sound like the correct path to getting GA and GTM working together correctly:
Since I have GA already up and running I wouldn't need the recipe for Pageviews mentioned in your post above, correct? Would adding that recipe send duplicate data to GA or is it required before I could just dive in with new/specific recipes?
Thanks again!
Ryan
How did you integrate the GTM code into your CustomJS? The code in our customJS file is all nested inside functions for the different parts we have in our custom JS. Inserting the code as is from the steps above doesn't seem to take and we lose our customJS changes. Did you insert the two snippets in the JS as one function or two possibly? I'll keep working the code but was hoping you could chime in.
Thanks.
Ryan
@simsrg ,
The file we upload to Canvas consists of a jQuery getScript() call to load a JavaScript file from one of our servers. The code Christopher listed above is added to that file as listed (outside of all other functions) and it doesn't interfere with any of our other JavaScript (and we have quite a bit):
// GOOGLE ANALYTICS
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');
var googleTagManager = '<!-- Google Tag Manager (noscript) -->' +
'<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>' +
'<!-- End Google Tag Manager (noscript) -->';
$('body').prepend(googleTagManager);
I cannot get Tag assistant to Connect after adding GA to my new container. I replaced the JS previously created with this post "How to Set Up Google Analytics for Canvas" (which had been working great!) with the following
// GOOGLE TAG MANAGER CODE(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','my id');
var googleTagManager = '<!-- Google Tag Manager (noscript) -->' + '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=my id" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>' + '<!-- End Google Tag Manager (noscript) -->';$('body').prepend(googleTagManager);
Any help would be great as I have to remove this JS file and put back the old one that worked.
To participate in the Instructure Community, you need to sign up or log in:
Sign In
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.