Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plugin | Simple Analytics
#1
Hey Guys,

As a proof of concept and simplicy, i have created a plugin for Google Analytics Code.

Simple Analytics 1.2
Allows you to enter your Google Analytics UA number and will automatically add the current google analytics code to the footer of your page, just before the </body> tag

Update Log
Fix: Have renamed all functions to avoid conflict with names of other functions in plugins.
Fix: Was allowing the display of analytics code after deleting ID from admin after first use. Will now delete the simpleanalytics.xml if the ID is blank in admin.
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#2
link?
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#3
Any instructions?

I dug around and found the field, and put a few variations of my UA ID and don't see the google code in any of the pages.
Reply
#4
Make sure that get_footer() is called somewhere in your theme, as this is where the plugin will be included.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#5
Right now I just have the default GS theme, and I don't see get_footer(). Where would I put that?

Thanks
Reply
#6
Where ever you want plugins to insert footer content. Just before </body> would probably work well.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#7
Sorry I always assumed get_footer was in the default theme?
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#8
crashfellow Wrote:Sorry I always assumed get_footer was in the default theme?
It is, but only since we've had the plugin system. I know it is in 2.01
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#9
I installed the plugin, but nothing happens. It appears as installed and that's all. How can I paste my google UI and where I don't know. It's not a big deal. I can insert it manually.
Reply
#10
ragou Wrote:I installed the plugin, but nothing happens. It appears as installed and that's all. How can I paste my google UI and where I don't know.

admin -> settings -> Google Analytics UA number (new field)
Reply
#11
Hi, I am having trouble getting this to work - I place 'get_footer()' above the body tag, and it just appears as text at the bottom of my page.

Could anyone tell me how I should wrap 'get_footer()' to get it to parse?

Thanks
Reply
#12
You should place the get_footer() call near the end of the template file, BEFORE the closing body tag, that is, like this:
Code:
...
<?php get_footer(); ?>
</body>
</html>

For a sample with div wrappers, look at the end of template.php of the Default_Simple theme. It's inside a <div id="footer">...

BTW, don't forget to put the tag between <?php and ?>
Reply
#13
Perfect. Thanks!
Reply
#14
Great work crashfellow!

Have a note: the newest Analytics code (see below) is changed and must also be placed before </head>-tag i.s.o. </body>-tag!

Code:
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxx-x']);
  _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);
  })();
</script>
Reply
#15
hi,

I can't get this plugin work. when I type analytics id in admin -> settings it disappear after the submit.
In data->other I can't see the xml file that is supposed to be generated by the plugin.
where it could be the problem?

plz help me with this
Reply
#16
ok solved by myself.
There is a bug in GetSimple 3.0 with the back-end hook "settings-cpsettings".
I've just re-downloaded the last version from the website and searched for this damned hook in all admin php files but I can't find it.

according to what you can see here http://phpkode.com/source/p/getsimple-cm...ttings.php
in the line 155 from 163 in settings.php there must be the following lines of code:

// create new cpsettings data file
$ufile = 'cp_settings.xml';
createBak($ufile, $path, $bakpath);
$xmlc = @new SimpleXMLElement('<item></item>');
$xmlc->addChild('HTMLEDITOR', @$HTMLEDITOR);
$xmlc->addChild('PRETTYURLS', @$PRETTYURLS);
$xmlc->addChild('PERMALINK', @$PERMALINK);
exec_action('settings-cpsettings');
XMLsave($xmlc, $path . $ufile);

but in my settings.php (I just want to remember that I'm working in a fresh and new downloaded version of GetSimple 3.0) I CANT FIND THESE lines of code.

so I just added "exec_action('settings-cpsettings');" (in my case what i'm damned loocking for) and..."tadaaaa" it works finally!

plz fix these bug as soos as possible.

P.S. sorry for my bad english Tongue
Reply
#17
Is this plugin worth updating to version 3+?

Have been out of get simple for a bit, and unsure if this functionality is now inbuilt into the system or not?
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#18
crashfellow Wrote:Is this plugin worth updating to version 3+?

Have been out of get simple for a bit, and unsure if this functionality is now inbuilt into the system or not?

No it is not built in yet. I would like to see this plugin being compatible with 3+. It is actually on my list of things to do, so if you do not want to, I will.
Reply
#19
Well i'm not that up on version 3, so if you believe you're able to do it, i'm happy for that.
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#20
crashfellow Wrote:Well i'm not that up on version 3, so if you believe you're able to do it, i'm happy for that.

Sure, Ill make it, it wont take but 15 minutes or so..

Does anyone have any suggestions on where/how I should include the code? I was thinking of including it with get_header() , however I am not sure how many use that tag.

I could leave it as it is and include the code with get_footer()
Reply




Users browsing this thread: 1 Guest(s)