Google tag manager
Hans Karlsen (talk | contribs) (Created page with "When you have tracking codes like from GoogleTagManager (GTM) or HubSpot or the like you will probably want them to signal per page. The problem is that a Single Page Applica...") |
Hans Karlsen (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
The problem is that a Single Page Application (SPA) like MDrivenTurnkey does not really switch page - and the tracker becomes unaware. | The problem is that a Single Page Application (SPA) like MDrivenTurnkey does not really switch page - and the tracker becomes unaware. | ||
<pre> | |||
<!-- Start of HubSpot Embed Code --> | |||
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/6033352.js"></script> | |||
<!-- End of HubSpot Embed Code --> | |||
<!-- HubSpot detect page change --> | |||
<script> | |||
(function () { | |||
var previousState = window.location.href; | |||
setInterval(function () { | |||
if (previousState !== window.location.href) { | |||
previousState = window.location.href; | |||
let page = previousState.split('#')[1]; | |||
var _hsq = window._hsq = window._hsq || []; | |||
_hsq.push(['setPath', page]); | |||
_hsq.push(['trackPageView']); | |||
console.log('HubSpot track '+page); | |||
} | |||
}, 800); | |||
})(); | |||
</script> | |||
</pre> |
Revision as of 14:41, 22 June 2022
When you have tracking codes like from GoogleTagManager (GTM) or HubSpot or the like you will probably want them to signal per page.
The problem is that a Single Page Application (SPA) like MDrivenTurnkey does not really switch page - and the tracker becomes unaware.
<!-- Start of HubSpot Embed Code --> <script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/6033352.js"></script> <!-- End of HubSpot Embed Code --> <!-- HubSpot detect page change --> <script> (function () { var previousState = window.location.href; setInterval(function () { if (previousState !== window.location.href) { previousState = window.location.href; let page = previousState.split('#')[1]; var _hsq = window._hsq = window._hsq || []; _hsq.push(['setPath', page]); _hsq.push(['trackPageView']); console.log('HubSpot track '+page); } }, 800); })(); </script>
This page was edited 97 days ago on 02/10/2024. What links here