PDA

View Full Version : Statcounter Tracking / Plugin


kwblue
08-03-2010, 12:30 PM
Hello,

I have been trying to find an answer to this here and on the .com site, but cannot seem to find it. Everyone wants the statcounter code in the templates, but I would like to create a plugin for it. (Why? Because I have multiple templates and do not want to have to put it in all the footers)

With that said.. How can I put <script> tags in a plugin? The counter doesn't appear to be tracking when it is put in there 'as is'.

The code is this:

<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=2089680;
var sc_invisible=1;
var sc_security="87f60d6a";
</script>

<script type="text/javascript"
src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div
class="statcounter"><a title="vBulletin analytics"
class="statcounter"
href="http://www.statcounter.com/vbulletin/"><img
class="statcounter"
src="http://c.statcounter.com/2089680/0/87f60d6a/1/"
alt="vBulletin analytics" /></a></div></noscript>
<!-- End of StatCounter Code -->


I also tried:

$output = '{code above}';

But didn't notice any tracking. Any help would be much appreciated! :)

vbplusme
08-09-2010, 03:20 PM
you need to put the javascript in a template and call the template with your plugin code.

for example create a template called mystatcounter, dump your block of code in there and save it. Then create a statcounter plugin with something like :

eval('$statcounter .= "' . fetch_template('mystatcounter') . '";');


then you just need to place $statcounter where ever you want the code to execute... HTH