cancel
Showing results for 
Search instead for 
Did you mean: 
victor
Community Contributor

How to add Google Analytics to a Canvas Page

Jump to solution

Hello,

How do I add GA to a Canvas Page?  I've tried putting in the code via the standard way, but it just strips out the code.  I'd like the ability to track usage on a public available free site on canvas's site.

Tags (1)
2 Solutions

Accepted Solutions
James
Community Champion

victor​,

This will be short since I have no personal experience using Google Analytics except as a user being tracked.

Google Analytics is already loaded on every Canvas Page. I know this because it's the one script I've got blocked when I run Canvas. It doesn't appear directly in the source code of the page, so you don't see it when you view the page source, but it's loaded from the common.js JavaScript file, which includes a bundle of a bunch of other JavaScript files. Without spending a lot of time digging into it, it looks like it's in the jquery.google-analytics.js file.

Now, the question becomes how does that help? Canvas is collecting the Google Analytics but I don't know if they share that with you in any way other than through the Analytics pages. Some of it is starting to show up in Canvas Data, but I'm not sure if that will be sufficient for your needs or you need to interact with Google Analytics directly.

I do remember going to a presentation at a previous InstructureCon (2013 or 2014) where a guy talked about using Google Analytics. At the time, it was my first introduction to what Google Analytics was and I was both blown away and freaked out at the same time.

Anyway, it was my understanding that he included the code in his Global Javascript file. That also seems to be what  @clong ​ is doing and he has a wonderful picture of his GA dashboard in this discussion: . Chris also wrote in Re: Google Analytics for Course Activity and FERPA  on October 15 and provided a link to a resource document he used, with modifications, to get it going

View solution in original post

clong
Community Champion

Hi Victor,

As mentioned adding Google Analytics would need to be done by adding the code to your institution's Global Javascript file. This is something that your Canvas admin will need to do. If you are just looking for some analytics on page views checkout Free Webpage Counter.  It works quite nicely in Canvas as long as you don't mind it being visible. If you need it to be invisible, you'll need to sign up for a free account and use something like StatCounter .

Also important to note that Google Analytics does NOT count any page views using the mobile Apps, just Web Browsers.

Here's a test page inside one of my Canvas courses you can view as a working example.

Does this help?

View solution in original post

7 Replies
josh_emmitt
Community Contributor

Hi Victor,

What was the "standard way" you tried? Was it an iframe? If not that could help, follow steps 3 and 4 on this guide Embedding a webpage in an assignment (iframes) to embed the analytics page into the rich content editor.

Hope this helps,

Josh

victor
Community Contributor

Thanks Josh,

It was just copy/paste the GA Code into the page via the HTML editor. 

Is there a non-iframe method or is that the only method?

josh_emmitt
Community Contributor

Hi Victor,

So far as I know this is the only way to get it embedded. There is an API for Google Analytics but it uses Javascript which will not work in Canvas at this stage.

The other option would be to use the redirect tool add a menu item to send the students to the Google Analytics page, but this does not embed it, rather it sends the students away from Canvas.

James
Community Champion

victor​,

This will be short since I have no personal experience using Google Analytics except as a user being tracked.

Google Analytics is already loaded on every Canvas Page. I know this because it's the one script I've got blocked when I run Canvas. It doesn't appear directly in the source code of the page, so you don't see it when you view the page source, but it's loaded from the common.js JavaScript file, which includes a bundle of a bunch of other JavaScript files. Without spending a lot of time digging into it, it looks like it's in the jquery.google-analytics.js file.

Now, the question becomes how does that help? Canvas is collecting the Google Analytics but I don't know if they share that with you in any way other than through the Analytics pages. Some of it is starting to show up in Canvas Data, but I'm not sure if that will be sufficient for your needs or you need to interact with Google Analytics directly.

I do remember going to a presentation at a previous InstructureCon (2013 or 2014) where a guy talked about using Google Analytics. At the time, it was my first introduction to what Google Analytics was and I was both blown away and freaked out at the same time.

Anyway, it was my understanding that he included the code in his Global Javascript file. That also seems to be what  @clong ​ is doing and he has a wonderful picture of his GA dashboard in this discussion: . Chris also wrote in Re: Google Analytics for Course Activity and FERPA  on October 15 and provided a link to a resource document he used, with modifications, to get it going

View solution in original post

clong
Community Champion

Hi Victor,

As mentioned adding Google Analytics would need to be done by adding the code to your institution's Global Javascript file. This is something that your Canvas admin will need to do. If you are just looking for some analytics on page views checkout Free Webpage Counter.  It works quite nicely in Canvas as long as you don't mind it being visible. If you need it to be invisible, you'll need to sign up for a free account and use something like StatCounter .

Also important to note that Google Analytics does NOT count any page views using the mobile Apps, just Web Browsers.

Here's a test page inside one of my Canvas courses you can view as a working example.

Does this help?

View solution in original post

awilliams
Community Champion
bertscjn
Community Member

@clong 

I've been trying to add Google Analytics to a .html file that I uploaded to the course's files that has Google Analytics coded. I took this file and embedded it into a Canvas page using <iframe>, but I could get Google Analytics to recognize this... 

So I tried your other suggestions and Stat Counter works great! I did my same steps as before, but this time with the Stat Counter code instead of Google Analytics code, and it works! I'm very pleased with the output of information that Stat Counter provides. However, the downfall is that it my analytics can be easily inflated, but it at least gives my team a baseline data point. Thanks for posting this!