Hi,
I would like to add a Piwk tracking code to the Admin CP for a variety of reasons, such as spotting fraudulent activities, monitoring/assessing new staff, etc etc...
However I don't think the Admin CP has templates in the same way the front end does.
My question is: where may I add tracking code? There is a javascript code and a noscript image tracking code.
Thanks!
its rather unusual requirement !
anyway, look in file
~/admin/inc/class_page.php#L228
if($mybb->debug_mode)
make empty line above it and there you can add required codes with
echo statements
echo "<script> ____________________ </script>";
however
please ensure that you add only
trusted script codes
Hi,
I've just tried this and unfortunately I'm now getting errors within the admincp:
Parse error: syntax error, unexpected 'text' (T_STRING), expecting ',' or ';' in /home/[domain]/public_html/web/admin/inc/class_page.php on line 228
The entire file:
http://pastie.org/private/lb9d2uxzkrr7grxspuz3q
Even Notepad++'s syntax highlighting doesn't like the tracking code I put in where most text under the code is gray; even after making it all one line, it still generates errors.
The tracking code is:
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDomains", ["*.boa-clan.com"]]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="TRACKING URL HERE";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 3]);
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);
})();
</script>
Changing "<script type="text/javascript">" to "<script>" also did nothing.
I even tried using the image tracking fallback but that didn't work either
please check if below code works
echo '<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDomains", ["*.boa-clan.com"]]);
_paq.push([\'trackPageView\']);
_paq.push([\'enableLinkTracking\']);
(function() {
var u="//URL-HERE";
_paq.push([\'setTrackerUrl\', u+\'piwik.php\']);
_paq.push([\'setSiteId\', 3]);
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);
})();
</script>';
Hi,
Excellent, works perfectly and the syntax highlighting shows the entire script in grey, which is how it should have been. The tracking works great. Thank you so much! Two more things:
1) Would you mind sharing what you did so I can learn please? I've compared my and your code and can't see an obvious difference?
2) In which page and where would I need to put the code to cover the login page?
Thanks!