|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
bsh Smarty Rookie
Joined: 16 Sep 2009 Posts: 5
|
Posted: Thu Sep 17, 2009 2:30 pm Post subject: Google Analytics plugin |
|
|
Code: | <?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Google Analytics plugin
* Generate XHTML 1.1 valid Google Analytics code
* Name: google_analytics<br>
* Date: 2009.09.17.<br>
*
* Examples:
* <pre>
* {google_analytics code=UA-xxxxxx-x}
* </pre>
*
* @author László Kovács <info@laszlokovacs.com>
* @license http://www.gnu.org/copyleft/gpl.html GPL
* @param array $params code parameter required
* @param Smarty $smarty
* @return string
*/
function smarty_function_google_analytics($params, &$smarty){
if(empty($params['code'])){
$smarty->trigger_error("google_analytics: missing parameter");
return;
}
$return = '
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
<script type="text/javascript">
// <![CDATA[
try{
var pageTracker = _gat._getTracker("'.$params['code'].'");
pageTracker._trackPageview();
} catch(err) {}
// ]]>
</script>';
return $return;
}
?> |
|
|
Back to top |
|
mifune Smarty n00b
Joined: 16 Dec 2009 Posts: 2
|
Posted: Wed Jan 20, 2010 10:52 am Post subject: |
|
|
hey, ... can someone give me a hand with this. i'm new to smarty and have not yet installed a plugin.
i guess, i have to create a file with the above code in the plugin folder.
but what would be the name of the file? function.google_analytics.php???
then i insert the code {google_analytics code=UA-xxxxxx-x} into my template.
thanks |
|
Back to top |
|
bsh Smarty Rookie
Joined: 16 Sep 2009 Posts: 5
|
Posted: Wed Jan 20, 2010 11:41 am Post subject: answer |
|
|
@mifune: yes |
|
Back to top |
|
newjav Smarty n00b
Joined: 21 Jan 2010 Posts: 3
|
Posted: Thu Jan 21, 2010 7:15 am Post subject: |
|
|
Thank You Very Much |
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
|
Back to top |
|
asmar Smarty n00b
Joined: 26 Oct 2008 Posts: 4
|
Posted: Fri Jan 06, 2017 8:31 pm Post subject: Re: Different way of implementing this |
|
|
The link you posted doesn't work.
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Jan 08, 2017 8:20 pm Post subject: |
|
|
Do check the post date. g.code repo was shut down several years ago. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|