Hi all,
Has anyone managed to setup Google Analytics 4?
This should work. I've got the rest of it working too, but this bit should take of loading it.
$.ajax({ url: 'https://www.googletagmanager.com/gtag/js?id=YOURID', dataType: 'script', cache: true, }) window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'YOURID');
Looking into it. But, w/o access to the of pages, it doesn't seem like an option. Am i wrong?
@martin_kabat
Did you find a way to use Google Analytics 4 in Canvas?
Regards
I have not. I tried using the Google provided tag inside our JS file, but that has not worked so I'm not sure what to do if we can't access the portion of the site where the tag needs to reside. I'd love it if somebody would be able to figure it out and comment here!
I believe the best solution for implementing Google Analytics 4 in Canvas is through the Google Tag Manager. Just follow the instructions provided by Christopher here: Using Google Tag Manager to add Google Analytics - Instructure Community (canvaslms.com)
You can also read the opening instructions provided in the earlier article that gave guidelines on how to implement Google Analytics: How to Set Up Google Analytics for Canvas (Archive... - Instructure Community (canvaslms.com)
Hello @martin_kabat, @dtod, et alia,
Below is our version which works perfectly, note the use of the UA tracking code, which works fine.
THese are the live feeds it produces with a single course added as a filter: https://lookerstudio.google.com/reporting/a1edcff7-926d-4810-8253-9ed15a3eaa23
I would now like to add all the other available dimensions https://portal.inshosteddata.com/docs and to publish the js file here for all to simply copy and paste (and sync in GA).
I'm going to have a go at it myself today but any guidance would be gratefully received.
Yours sincerely,
@JedKeenan
function g() {window.addEventListener("load", function () {ENV.current_user_roles.indexOf("teacher") >= 1 &&[...document.querySelectorAll(".teacher-only")].forEach((e) => {(function (e, o, t, a, n, s, r) {(e.GoogleAnalyticsObject = n),(e[n] =e[n] ||function () {(e[n].q = e[n].q || []).push(arguments);}),(e[n].l = 1 * new Date()),(s = o.createElement(t)),(r = o.getElementsByTagName(t)[0]),(s.async = 1),(s.src=a),r.parentNode.insertBefore(s, r);})(window, document, "script", "https://www.google-analytics.com/analytics.js", "gtag");function v(e) {try {localStorage.removeItem(e), localStorage.removeItem(e + "_expiresIn");} catch (o) {return console.log("removeStorage: Error removing key [" + e + "] from localStorage: " + JSON.stringify(o)), !1;}return !0;}function h(e) {var o = Date.now(),t = localStorage.getItem(e + "_expiresIn");if ((t == null && (t = 0), t < o)) return v(e), null;try {var a = localStorage.getItem(e);return a;} catch (n) {return console.log("getStorage: Error reading key [" + e + "] from localStorage: " + JSON.stringify(n)), null;}}function w(e, o, t) {t == null ? (t = 24 * 60 * 60) : (t = Math.abs(t));var a = Date.now(),n = a + t * 1e3;try {localStorage.setItem(e, o), localStorage.setItem(e + "_expiresIn", n);} catch (s) {return console.log("setStorage: Error setting key [" + e + "] in localStorage: " + JSON.stringify(s)), !1;}return !0;}async function _(e) {let t = await (await fetch("/api/v1/users/self/courses?per_page=100")).text();(t = t.replace("while(1);", "")), (t = JSON.parse(t));var a = JSON.stringify(t);w("ga_enrollments", a, null);var n = f(e, a);return n;}function f(e, o) {if (o != null) {let a = JSON.parse(o);for (var t = 0; t < a.length; t++) if (a[t].id == e) return a[t];}return null;}function u(e) {gtag("set", "dimension4", e.id),gtag("set", "dimension5", e.name),gtag("set", "dimension6", e.account_id),gtag("set", "dimension7", e.enrollment_term_id),gtag("set", "dimension8", e.enrollments[0].type),gtag("send", "pageview");}function m(e) {var o, t, a, n;if ((gtag("create", e, "auto"),(o = ENV.current_user_id),(t = ENV.current_user_roles),gtag("set", "userId", o),gtag("set", "dimension2", o),gtag("set", "dimension3", t),(n = window.location.pathname.match(/\/courses\/(\d+)/)),n)) {(n = n[1]), (a = 0);try {let r = h("ga_enrollments");if (r != null) {var s = f(n, r);s === null? _(n).then((l) => {l === null ? (gtag("set", "dimension4", n), gtag("send", "pageview")) : u(l);}): u(s);} else_(n).then((l) => {l === null ? (gtag("set", "dimension4", n), gtag("send", "pageview")) : u(l);});} catch {if (((a += 1), a > 5)) {gtag("set", "dimension4", n), gtag("send", "pageview");return;}}} else gtag("send", "pageview");}i();g();d();globalThis.DT_variables = c;m("UA-XXXXXXXXX-1");})();
Hi everyone, I am seeking some insight into how Canvas LMS handles HTTP errors and how they are reflected in the logs versus the user interface. We are currently observing the following behavior in our environment: Log-only errors: We are seeing 500 (Internal Server Error) and 503 (Service Unavailable) errors recorded in…
I'm currently integrating an LTI tool and attempting to use the Activity.id.history https://canvas.instructure.com/doc/api/file.tools_variable_substitutions.html#activity-id-history variable, but I'm experiencing issues getting it to work properly. What I've Done: Added the Activity.id.history variable to my Developer…
I looked through the LTI Variable Substitutions documentation and while there are variable substitutions available for Canvas.term.name and Canvas.term.id (which is the Canvas incremented ID like "104"), I was surprised to see there was no option for Canvas.term.sisSourceId I tried testing other possible variants that may…
Summary:The Learning Mastery Gradebook allows drag-and-drop reordering of outcome columns, and this triggers a call to /api/v1/courses/:course_id/assign_outcome_order. The API returns 204 No Content (success), but the column order does not persist after page refresh. Steps to Reproduce: Open Learning Mastery Gradebook for…
I'm building a tool for my institution that imports grades from another LTI tool into Canvas so instructors can automate late assignment policies not otherwise supported by Canvas. I'm trying to use the LTIv1.3 ID which is readily available on the LTI-side as a link to the student record on Canvas, but I can't find the ID…