Tracelines 0 Report post Posted May 28, 2015 Quick Guide: Implement Google Analytics Using meta.php [Last updated: 05-28-2015]Any corrections/modifications welcome. Hope this might help someone.Create a Google Analytics [GA] account and add your url to obtain your customized GA tracking code.Create a file (preferably using Notepad++ or another html editor) and name it“analyticsTracking.php” and paste the GA tracking code into it. It should look something like this:<script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type="text/javascript">var pageTracker = _gat._getTracker("INSERT YOUR ID HERE");pageTracker._trackPageview();</script> <?php// End Analytics tracking code?> Place “analyticsTracking.php” file in the same directory as “meta.php”.Give “analyticsTracking.php” the following permissions: 644 (i.e. -rw-rw-r--)Edit “meta.php”, by adding the following line:<?php include_once("analyticstracking.php") ?>Your meta.php should end up looking like this:<?php global $cms; ?> <?php include_once("analyticstracking.php") ?> Share this post Link to post Share on other sites
Arnaud 0 Report post Posted November 12, 2018 This is a great article. Thanks. Just mind that there is one small "error" in it, for users running the TNG software on a server with a case-sensitive operating-system (= probably the majority of users): The suggested filename for the script has an upper-case T in the name "analyticsTracking.php", whereas the call in the meta.php file does only have lower-case characters. On webservers running linux this is causing a problem, because this OS is case-sensitive. So, either change the filename to analyticstracking.php, or use an upper-case T in the call from meta.php. Regards, Arnaud Share this post Link to post Share on other sites
jgrubbs 0 Report post Posted August 1, 2020 Just curious, is there a reason why we need to put the Google Analytics code into it's own php file to call as a include in the meta.php vs. just putting the Google Analytics code into the meta.php? Share this post Link to post Share on other sites
dunthene 0 Report post Posted March 7 Maybe this instruction is now out of date?? 2015!! In any case it did not work for me ... i had to following the instructions here on Google Analytics site .. where it directs to paste the include link to the created tracking file <?php include_once("analyticstracking.php") ?> just after the <body> tag in the topmenu.php file in the appropriate template directory (#12 in my case) ... just like this. <body id="bodytop" class="<?php echo pathinfo(basename($_SERVER['SCRIPT_NAME']), PATHINFO_FILENAME); ?> publicbody"> <?php include_once("analyticstracking.php") ?> <a name="top"></a> <div id="cb-main"> . . . then i got analytical data at my google analytics account. Share this post Link to post Share on other sites