I know that title sounds like it might be for a hair gel, but it’s actually for a new WordPress plugin I’ve had developed called “Scripts Manager”.
Here’s the situation I’ve been in umpteen times, and I’m sure you’ve either hit it yourself or at least you will eventually, it’s just a matter of time.
First the background…
A plugin like Slide Up Ads will automatically insert the javascript required to make it work into all the pages and posts within WordPress.
You just activate the plugin and it’s done.
But I’ve found there are plenty of instances when I’ve wanted or needed to use an external non-WordPress script which requires me to add some javascript to all my pages manually.
For instance, imagine you need to insert some tracking code or another bit of javascript on all (or most of) your WordPress posts and pages.
Usually, either the code has to go into the header above the </head> tag, or it needs to go into the footer, just above the </body> tag.
The only way that WordPress allows you to do this is to go into the theme editor and update the themes header.php or footer.php to include your code.
Now that might seem okay, but in practice what happens is a few weeks down the line, a new version of your theme is released and you update it. Or you find a better theme and decide to use that instead.
This has happened to me, and I figure it must have happened to you too.
When you update or change your theme, all the code modifications you put in get overwritten. D’oh!
More than once I’ve found I have several days tracking missing from one of my sites, all because I forgot to get the tracking code and place it into the updated version of the theme. (I use the StatCounter.com tracking service, and it’s well worth it.)
You’d think I’d learn, but it just seems to be one of my blind spots…
At this point you might be smugly thinking, “Ah, I use the free Google Analytics for my tracking, and I have a plugin that does that for me.” 😉
My advice for what it’s worth is to get rid of GA immediately. This is a prime example of the case where many people follow the crowd and put themselves in a situation where they hadn’t even considered the consequences.
This is what those consequences can be…
If you use GA or AdSense, then a competitor can pay a few dollars and find every single one of your websites. (I’ve actually done this myself to study the structure of how one of my competitors was working his network of sites.)
And of course the other BIG downside to GA and AdSense is that if you upset Google, they can easily de-index ALL your sites because you’ve kindly let them know where they all are by adding tracking code to them.
The crowd is often wrong (1 in 5 times – 80:20 rule), and if you think hard about things and then follow a different path you’re much more likely to have the edge and to succeed.
That’s been my personal experience.
So I decide to get this plugin created to end once and for all the problem of updating and changing themes, and losing my StatCounter code.
And of course, I made it a little more flexible than I actually needed it to be, because… well you never know when it might come in handy.
Once you’ve installed and activated the plugin, you’ll see there’s a new admin section where you can paste your metatags and javascript into the appropriate area.
In that section, there are global areas where the contents of each will appear on every post and page.
These global areas are for:-
- Header Scripts
- Footer Scripts
- Onload Scripts
That last one is for those unusual little instances where you need to run the script after the rest of the page has been loaded.
(I found recently that by using this plugin, it solved a problem with a script where all the pages on my blog were being blanked out in the Opera browser, but not in IE, FireFox or Safari. Very strange, but now fixed.)
And then we took it a little bit further, because in some cases you might only want your code to appear on certain pages. 😉
So on every page and post in the admin panel, there’s a new section underneath the editor where you can either:-
- Overwrite the global settings.
- Append BEFORE the global settings.
- Append AFTER the global settings.
Between the global and the post/page settings, this gives you total flexibility over where your scripts are active on your site. 🙂
On Friday (5th) afternoon, 50 copies of the plugin will be available for just $7. When all 50 copies are gone I’ll set the regular price, but you’ll get it at a very nice discount until then.
Watch for a new blog post tomorrow.
-Frank Haywood
Hi Frank
That is one awesome plugin – Many people may not think so but I ran into a similar problem on a niche site that I needed some of my own visitor tracking –
and guess what I did just as you mentioned – added it into the bottom of the footer page and….
what hapenned ?
The Revolution lifestyle featured content dissapeared.
So I had to leave out the tracking on that particular blog as I did not want to add GA ( for reasons that you mention in your post)
So I am for one will be getting it as soon as its available not just for my reason but also the fact that I do change my themes occasionally and so easy to forget that you have added extra snippets into the pages
Thanks and look forward
Hamant
The
@Hamant Keval:
You’re right, and that’s something I hadn’t even considered. Some of the cleverer themes that extend past standard WordPress functionality will break if you add code to them, and that exact same thing has happened to me in the past.
Thanks for pointing that out to me.
-Frank
Great idea Frank! I especially like the heads up about GA and will be signing up today with StatCounter.com. I had wondered some times about adding some js to my site but didn’t for some of the reasons you mentioned. Plus, I’m still learning WP and I’m very hesitant at times to start messing with the code. Looking forward to using this plugin.
@Derek Taylor:
It’s a cool plugin, no mistake. 😉
There are services other than StatCounter.com, but for sheer value for money, it beats them all hands down, and it gives you a lot more detail than GA does. There’s no doubt that GA *could* supply all the information that StatCounter does, but I think they probably keep all that for themselves. Because yes of course, Google has access to all the stats that everyone all over the world are generating for them…
-Frank
I wanted to buy it. I have looked and looked for the announcement and link to the sale. It has never come. It is 4 pm U.S. Central time now, so I’m pretty sure I did not get the notice.
Yet I got the teaser that it was coming. Why?
@Kathleen Gresham:
I’m not sure what happened, but I tend to announce all new releases on this blog (for now) by creating another post, so you can always check here at the time the sales starts.
Maybe the announce email got bounced or ended up in your spam box?
-Frank