Skip to content

Commit

Permalink
SAK-29668
Browse files Browse the repository at this point in the history
Add Support for Google Tag Manager to the Portal
  • Loading branch information
Miguel Carro Pellicer committed Jul 9, 2015
1 parent 7dae9f0 commit fe3bb7e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
#
# portal.google.universal_analytics_id=UA-XXXXXX-XX

# SAK-29668
# Add support for Google Tag Manager
# Google Tag Manager is NOT enabled by default, setting these will enable it
# portal.google.tag.manager.container_id = GTM-XXXXX

# SAK-29138 - If set to true, portal will use student's enrolled section title (of preferred type, see below)
# rather than the site's title for the course site tab, page (browser tab) title, and tool header title
# DEFAULT: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,12 @@ public PortalRenderContext startPageContext(String siteType, String title,
ServerConfigurationService.getBoolean("portal.google.analytics_detail", false));
}

//SAK-29668
String googleTagManagerContainerId = ServerConfigurationService.getString("portal.google.tag.manager.container_id", null);
if ( googleTagManagerContainerId != null ) {
rcontext.put("googleTagManagerContainerId", googleTagManagerContainerId);
}

Session s = SessionManager.getCurrentSession();
rcontext.put("loggedIn", Boolean.valueOf(s.getUserId() != null));
rcontext.put("userId", s.getUserId());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#if (${googleTagManagerContainerId})
<!-- START includeGoogleTagManager.vm -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=${googleTagManagerContainerId}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(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=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','${googleTagManagerContainerId}');</script>
<!-- END includeGoogleTagManager.vm -->
#end ## END of IF (${googleTagManagerContainerId})
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@

#parse("/vm/morpheus/includeCookieNotice.vm")

#parse("/vm/morpheus/includeGoogleTagManager.vm")

${includeExtraHead}
</body>
</html>

0 comments on commit fe3bb7e

Please sign in to comment.