Last active
August 29, 2015 13:57
-
-
Save luisabarca/9362557 to your computer and use it in GitHub Desktop.
Track logged in user with piwik
This file contains hidden or 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
<?php | |
$uname = ''; | |
$user =& JFactory::getUser(); | |
if ( is_object($user) ) { | |
$uname = $user->name; | |
} | |
?> | |
<!-- Piwik --> | |
<script type="text/javascript"> | |
var _paq = _paq || []; | |
<?php if (!empty($uname)): ?> | |
_paq.push(["setCustomVariable", 1, 'User', '<?php echo $uname; ?>', "visit"]); | |
<?php endif ?> | |
_paq.push(["trackPageView"]); | |
_paq.push(["enableLinkTracking"]); | |
(function() { | |
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://enovate.us/"; | |
_paq.push(["setTrackerUrl", u+"piwik.php"]); | |
_paq.push(["setSiteId", "2"]); | |
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; | |
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment