Need 2 Plugins Created

Need a plug in that will allow you to insert html before the /head tag

and a second that will insert before the /body

This plug in is to make it simple to add the new google analytics code required to be before the /head tag now and for other scripts that require parts in the /head and /body sections.

Comments

  • @usfhane Have you looked at the GoogleAnalytics plugin?
  • Yes and it looks like it is the old system that would go before the /body

    The updated Google analytics along with quantcast now uses asynchronous tracking. This seems to be the new standard...

    Quantcast actually requires 2 parts of code for this one in the /head and one in the /body

    So I was hoping that I could accomplish this with a template edit, but it looks like the way the code is written, a plugin is about he only way to do it. I looked at the TPL folder but it looks like that is not the right route either.


    Here is the new Google Code


    <script type="text/javascript">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXX-XX']);
    _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>
  • ohh i just noticed that part of my post was taken out

    so i need to be able to split between the head and body tags...

    wow that makes my post hard to read lol
  • @ufshane try using the code tag <code> before your code and closing it after
  • Yah I just took out the >< so that you could see it... so back to the topic at hand
  • @ufshane have you tried the current plugin? From what I've read there's no difference between the content regular and asynchronous analytics gives you.
  • Yes but it does not solve the problem with quantcast...
  • @ufshane I suggest looking at the GA plugin and attempting to modify it for Quantcast, it should be rather straightforward.
  • I guess i need to understand how to get the plugin to know the difference between putting the code in the head section vs the body section...

    I am not the greatest coder in the world
  • @ufshane me neither, sorry =\
  • ok so for the time being... i am using the old code with the GA plugin and did an include statement to pull the quantcast code into the plugin...

    I would highly recommend creating a standard plugin for the head and body sections individually... this will allow for a lot of the requests I see here to be met... things like custom footers that do not touch the original code and using scripts that require a split implementation.
  • @ufshane I think there might be some existing hooks you can use to meet your plugin placement requirements.
    1. To add something before the </head> tag, you can use the existing EndShowHeadElements hook.
    2. To add something before the </body> tag, you can use the existing EndShowScripts hook. This is where you can also add .js, for page load efficiencies and whatnot.
    Maybe for you, a new plugin would go in the same place as the GoogleAnalytics plugin. To accomplish a clean custom plugin (instead of the hack to the GoogleAnalytics one), you can essentially use GoogleAnalytics as your template. You'd want to store it locally as local/plugins/Quantcast/QuantcastPlugin.php or something similar though. And don't forget to addPlugin it in your config.php.

    Let me know if you need more help.
  • Hey thanks RLS, I will work on that this weekend...
  • @ufshane Great, let me know how it goes!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID