Created
August 27, 2021 08:44
-
-
Save kgolebiowski/419aa5d6d2de461fef45bea22f85b273 to your computer and use it in GitHub Desktop.
Liferay 7.0 Piwik/Matomo integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Piwik --> | |
<script type="text/javascript"> | |
var _paq = _paq || []; | |
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ | |
_paq.push(['trackPageView']); | |
_paq.push(['enableLinkTracking']); | |
(function () { | |
var u = "//example.com/"; | |
_paq.push(['setTrackerUrl', u + 'piwik.php']); | |
_paq.push(['setSiteId', '1']); | |
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; | |
g.type = 'text/javascript'; | |
g.async = true; | |
g.defer = true; | |
g.src = u + 'piwik.js'; | |
s.parentNode.insertBefore(g, s); | |
})(); | |
(function(history){ | |
var pushState = history.pushState; | |
history.pushState = function(state) { | |
if (typeof history.onpushstate == "function") { | |
history.onpushstate({state: state}); | |
} | |
var returnedVal = pushState.apply(history, arguments); | |
var currentUrl = location.href; | |
_paq.push(['setReferrerUrl', currentUrl]); | |
_paq.push(['setCustomUrl', currentUrl]); | |
_paq.push(['setDocumentTitle', arguments[1]]); | |
_paq.push(['trackPageView']); | |
return returnedVal; | |
} | |
})(window.history); | |
</script> | |
<!-- End Piwik Code --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment