Extension talk:Google Analytics Integration/Archive

NOTE - Please install new version
Please install the latest version! As seen below - The initial release of the extension was not returning 'true' properly, which causes errors in MW 1.11+ and halts further processing on the specified Hook in every version! (not cool)

I installed this extension on my MW 1.11(Alpha). Got Following error.
(Note I have removed my hosting a/c name and put XXXXX instead for obvious reason.)

MediaWiki internal error. Original exception: exception 'MWException' with message 'Detected bug in an extension! Hook googleAnalyticsHook failed to return a value; should return true to continue hook processing or false to abort.' in /home/XXXXX/public_html/wiki/includes/Hooks.php:133 Stack trace: Exception caught inside exception handler: exception 'MWException' with message 'Detected bug in an extension! Hook googleAnalyticsHook failed to return a value; should return true to continue hook processing or false to abort.' in /home/XXXXX/public_html/wiki/includes/Hooks.php:133 Stack trace: MonoBookTemplate->execute('MonoBookTemplat...', Array)
 * 1) 0 /home/XXXXX/public_html/wiki/skins/MonoBook.php(225): wfRunHooks
 * 2) 1 /home/XXXXX/public_html/wiki/includes/SkinTemplate.php(463): MonoBookTemplate->execute('MonoBookTemplat...', Array)
 * 3) 2 /home/XXXXX/public_html/wiki/includes/OutputPage.php(683): SkinTemplate->outputPage
 * 4) 3 /home/XXXXX/public_html/wiki/includes/Wiki.php(301): OutputPage->output(Object(OutputPage))
 * 5) 4 /home/XXXXX/public_html/wiki/index.php(90): MediaWiki->finalCleanup
 * 6) 5 {main}
 * 1) 0 /home/XXXXX/public_html/wiki/skins/MonoBook.php(225): wfRunHooks
 * 2) 1 /home/XXXXX/public_html/wiki/includes/SkinTemplate.php(463):
 * 1) 2 /home/XXXXX/public_html/wiki/includes/OutputPage.php(683): SkinTemplate->outputPage
 * 2) 3 /home/XXXXX/public_html/wiki/includes/Exception.php(86): OutputPage->output(Object(OutputPage))
 * 3) 4 /home/XXXXX/public_html/wiki/includes/Exception.php(111): MWException->reportHTML
 * 4) 5 /home/XXXXX/public_html/wiki/includes/Exception.php(191): MWException->report
 * 5) 6 /home/XXXXX/public_html/wiki/includes/Exception.php(225): wfReportException
 * 6) 7 [internal function]: wfExceptionHandler
 * 7) 8 {main}

-Gautam
 * Thx! The posted code should be working now.

runonloadhook
Tim, thanks for making this great extension. If you look at the code of any page in MW, you'll see near the end: if (window.runOnloadHook) runOnloadHook; Wouldnt using this hook (if possible) be a better way because GA advises to use the code just before the body tag? This hook is about just before the body tag. --Kenny5 19:11, 2 September 2007 (UTC)


 * If you run this extension on 1.11alpha+, you'll notice that the GA code actually shows up BELOW that script line. I added a new hook to the core (SkinAfterBottomScripts) specifically designed for JS-powered analytics engines.  I talked to the guys over at Google regarding the tag placement and they said that as long as Google is receiving data, the tag placement is fine.  There are certain locations where the script will not be executed properly and that's why they say put it at the bottom.  Either way, if you get data in your GA reports, you're good - and once 1.11 comes out, the extension utilizes the new hook that puts the script tag at the absolute bottom of the page.
 * Ah I see, great then. I'll wait for the upgrades then. Thanks for all your research in this. And I just checked and am getting the data even with my 1.9.3 (should have mentioned before) so this is great. This extension is great, I didnt have to alter the internal files in any way (which is always the goal). thanks again --Kenny5 19:35, 2 September 2007 (UTC)

Bottom of page; older version
I installed this and the script is not at the bottom of the page--though fairly near it. I'm using version 1.8. Right now when I go to google analytics and click the "check status" button it says that the tracking code hasn't been detected. What I'm guessing is that the detection mechanism specifically is looking for this at the bottom of the page but that, regardless it is working. I hope!. Anyway, I'll verify by checking back with google analytics in a few days and see if they are gathering any datat. Then I'll report the results here. Thanks for the extension! --Matthew (76.27.82.88 04:33, 14 September 2007 (UTC))
 * Let me know if you don't receive any data within 48 hours of installing the extension. GA seems to be 2-3 days behind at all times.  It should work even though it's not at the bottom, I talked to the GA guys when I wrote the extension.  ;-)

New GoogleAnalytics script
Changing this part of the code will incorporate the new GoogleAnalytics script: $funcOutput = "\n". "var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\n". "document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));\n". " \n". "\n". "var pageTracker = _gat._getTracker(\"" . $googleAnalytics . "\")\n". "pageTracker._initData;\n". "pageTracker._trackPageview;\n". " \n"; --Jdj 02:21, 28 December 2007 (UTC)
 * Implemented support for the new ga.js script in r29077. Thx for the note, I wasn't aware they had a new script available.  Also, check the code - f/ large string chunks like that, HEREDOC syntax is much cleaner.  ;-)  Tim Laqua talk 22:05, 30 December 2007 (UTC)