Merge ~ya-bo-ng/maas:replace-ga-with-gtm into maas:master

Proposed by Anthony Dillon
Status: Merged
Approved by: Anthony Dillon
Approved revision: 424823d96947f8e226f05de348b99d448eab8841
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ya-bo-ng/maas:replace-ga-with-gtm
Merge into: maas:master
Diff against target: 50 lines (+16/-4)
3 files modified
src/maasserver/templates/maasserver/base.html (+8/-0)
src/maasserver/templates/maasserver/index.html (+8/-0)
src/maasserver/templates/maasserver/js-conf.html (+0/-4)
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
MAAS Lander Approve
Review via email: mp+354419@code.launchpad.net

Commit message

Replace GA script with GTM

Description of the change

Replacing the Google Analytics snippet with the Google Tag Manager snippet. Allowing us to enable Usabilla and GA remotely.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b replace-ga-with-gtm lp:~ya-bo-ng/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: ac594f661166b4b730549bf77f45f83b818c2591

review: Approve
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Your missing the removal of the analytics in main.js.

review: Needs Fixing
~ya-bo-ng/maas:replace-ga-with-gtm updated
e6efea4... by Anthony Dillon

Remove the GA function from main.js

Revision history for this message
Anthony Dillon (ya-bo-ng) wrote :

Thanks Blake, removed the function. Ready for review again.

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b replace-ga-with-gtm lp:~ya-bo-ng/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: e6efea4fe342fd32e58cbf26eeaed88e34f02d82

review: Approve
Revision history for this message
Blake Rouse (blake-rouse) wrote :

This issue is now you will not get new page views. The code you removed updated the current page even in a SPA, which MAAS mostly is (only some settings pages are not).

The reason this was linked to angular code is because of this:

$rootScope.$on('$routeChangeSuccess', function() {});

This is called when the HTML5 route is changed, something that you are completely losing with your change.

review: Needs Fixing
~ya-bo-ng/maas:replace-ga-with-gtm updated
424823d... by Anthony Dillon

Add back the state change GA event function

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b replace-ga-with-gtm lp:~ya-bo-ng/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 424823d96947f8e226f05de348b99d448eab8841

review: Approve
Revision history for this message
Anthony Dillon (ya-bo-ng) wrote :

Blake, can you have a look at this again. I have checked and the current event push still works with GTM.

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Okay, if it works with the existing angular code then cool.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/templates/maasserver/base.html b/src/maasserver/templates/maasserver/base.html
2index fc65508..5ab7aaf 100644
3--- a/src/maasserver/templates/maasserver/base.html
4+++ b/src/maasserver/templates/maasserver/base.html
5@@ -14,6 +14,14 @@
6 <base href="{% url 'index' %}">
7 <title>{% block title %}{% endblock %} | {% include "maasserver/site_title.html" %}</title>
8
9+ {% if global_options.enable_analytics %}
10+ <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
11+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
12+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
13+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
14+ })(window,document,'script','dataLayer','GTM-P4TGJR9');</script>
15+ {% endif %}
16+
17 <link rel="shortcut icon" href="{{ STATIC_URL }}assets/images/icons/maas-favicon-32px.png">
18
19 <!-- stylesheets -->
20diff --git a/src/maasserver/templates/maasserver/index.html b/src/maasserver/templates/maasserver/index.html
21index ff2b1ae..804f3bf 100644
22--- a/src/maasserver/templates/maasserver/index.html
23+++ b/src/maasserver/templates/maasserver/index.html
24@@ -14,6 +14,14 @@
25 <base href="{% url 'index' %}">
26 <title data-ng-bind="title + ' | ' + site + ' MAAS'"></title>
27
28+ {% if global_options.enable_analytics %}
29+ <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
30+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
31+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
32+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
33+ })(window,document,'script','dataLayer','GTM-P4TGJR9');</script>
34+ {% endif %}
35+
36 <link rel="shortcut icon" href="{{ STATIC_URL }}assets/images/icons/maas-favicon-32px.png">
37
38 {% include "maasserver/css-conf.html" %}
39diff --git a/src/maasserver/templates/maasserver/js-conf.html b/src/maasserver/templates/maasserver/js-conf.html
40index c3ec0d6..353e7d8 100644
41--- a/src/maasserver/templates/maasserver/js-conf.html
42+++ b/src/maasserver/templates/maasserver/js-conf.html
43@@ -36,7 +36,3 @@ var MAAS_config = {
44 <script type="text/javascript"
45 src="{{STATIC_URL}}/js/bundle/maas-min.js?v={{files_version}}">
46 </script>
47-
48-{% if global_options.enable_analytics %}
49-<script async src='https://www.google-analytics.com/analytics.js'></script>
50-{% endif %}

Subscribers

People subscribed via source and target branches