Skip to content

Commit

Permalink
feat: Add Google Analytics tracking to top bar component
Browse files Browse the repository at this point in the history
  • Loading branch information
little9 committed Jul 17, 2024
1 parent 8f96690 commit 00d271a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 0 additions & 8 deletions 01JHU_INST-JHU/html/prm-top-bar-before.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
<custom-alert-banner parent-ctrl="$ctrl"></custom-alert-banner>
<!-- end custom alert -->

<!-- Google Tag Manager -->
<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=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-KVWVGLP');</script>
<!-- End Google Tag Manager -->

<div class="jh-header-container" aria-label="main">
<div class="jh-header-logo">
<a href="../" title="JH Libraries Homepage">
Expand Down
16 changes: 15 additions & 1 deletion src/components/prmTopBarBefore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
export const prmTopBarBefore = {
bindings: { parentCtrl: `<` },
templateUrl: "/discovery/custom/01JHU_INST-JHU/html/prm-top-bar-before.html"
templateUrl: "/discovery/custom/01JHU_INST-JHU/html/prm-top-bar-before.html",
controller: ['$scope', function ($scope) {
var ctrl = this;

ctrl.$onInit = function () {
(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-KVWVGLP');
}
}]
};

0 comments on commit 00d271a

Please sign in to comment.