Jifty::Plugin::GoogleAnalytics - Replace "</body>" by Google Analytics Javascript code dynamically.
Add the following to your site_config.yml
framework: Plugins: - GoogleAnalytics: javascript: | <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("UA-*******-*"); pageTracker._initData(); pageTracker._trackPageview(); </script>
If you need disable it in some cases, then
# in Mason template ... <%init> Jifty->web->request->argument( use_google_analytics => 0 ); </%init> ... # in Template::Declare ... template "example" => page { set use_google_analytics => 0; }; # in YourApp::Dispatcher (Mason template only) ... on qr{^/download} => [ run => { set use_google_analytics => 0; }, ]; ...
Jifty, Text::OutputFilter
bokutin, <bokutin at cpan.org>
<bokutin at cpan.org>
Copyright 2008 bokutin, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Jifty::Plugin::GoogleAnalytics, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Jifty::Plugin::GoogleAnalytics
CPAN shell
perl -MCPAN -e shell install Jifty::Plugin::GoogleAnalytics
For more information on module installation, please visit the detailed CPAN module installation guide.