1
wishcraft
Preloaders and things like Google Analytics

If you happen to know about Google Analytics some of the easiest way of loading the analytics in the theme is like so.

You create a file in /modules/system/preloader called analytics.php and put the following code in, remember to replace UA-00000000-0 with your analytics account code and the other settings:

defined('XOOPS_ROOT_PATH') or die('Restricted access');

class 
SystemAnalyticsPreload extends XoopsPreloadItem
{
      function 
eventCoreHeaderAddmeta($args)
    {
        if (
is_object($GLOBALS['xoTheme'])&&!isset($GLOBALS['analytics'])) {
            
$GLOBALS['analytics'] = true;
            
$GLOBALS['xoTheme']->addScript('', array('type' => 'text/javascript'), "  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-00000000-0']);
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();"
);
        }
    }
    
    function 
eventCoreFooterEnd($args) {
        unset(
$GLOBALS['analytics']);
    }
}


You will find the code that google gives you if you need to change anything quiet similar to this code and there will be only minor fields to change.
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

2
deka87
Re: Preloaders and things like Google Analytics
  • 2011/11/16 8:39

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


thanks wishcraft. that is better then editing theme.html
Mind anchors

Login

Who's Online

126 user(s) are online (66 user(s) are browsing Support Forums)


Members: 0


Guests: 126


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits