Posts Tagged ‘web’

Three things to add to every Wordpress theme function file

// February 23rd, 2010 // No Comments » // tagged: > >

I develop a lot of wordpress sites and always try to customize the site with as few plugins as possible. Many people use plugins for something that can EASILY be done with a few lines of code in your themes functions.php file.

Here are three functions.php edits I use on every single new wordpress install:

Custom Login Screen – 4 lines of code

With three lines of code you can customize your login screen with your logo.  Easy peasy. Upload your logo to your themes directory — change the file name — and wala.  Good to go.

function my_custom_login_logo() {
  echo '<style type="text/css">h1 a { background-image:url('.get_bloginfo('template_directory').'/yourlogo.jpg) !important; }</style>';
   }
add_action('login_head', 'my_custom_login_logo');

Remove wordpress update notice – 5 lines of code

I don’t want my end users seeing the wordpress update notice when they login.  I see it … that’s enough.  I don’t need emails from them telling me about it :)

add_action('admin_menu','bhhidenag');
function bhhidenag()
{
remove_action( 'admin_notices', 'update_nag', 3 );
 }

Remove all those extra links in the header – 9 lines of code (max)

Most of my wordpress sites aren’t blogs … and so I remove a lot of the bloggy links from the header.  You can pick and choose which ones you want to leave.  I never include the generator line because that just announces to the world what version of WP your site is running … “hello hackers, try to exploit me with my known bugs”.  LOL

remove_action( 'wp_head', 'feed_links_extra', 3 ); // extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // general feeds: Post and Comment Feed
remove_action( 'wp_head', 'rsd_link' ); // Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link' ); // Windows Live Writer manifest file.
remove_action( 'wp_head', 'index_rel_link' ); // index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator' ); // WP version

Two Ways to Use Google Analytics Better

// July 30th, 2009 // 2 Comments » // tagged: > > >

Google Analytics provides GREAT data straight “out of the box”… I use it for every site I build. Recently – I started doing two new things with GA.

  • Tracking how effective specific ads (some regular ol’ plain text links too) were. We have a flash ad rotation on several of our sites … and I wanted to know how many people were clicking on what specific ads to get to other sections of the site. I wanted to know more than just “they came from the homepage”.  I wanted to know – did they click on the Antarctica ad or the New Zealand ad?  Did they click on the text link in the navigation?
  • Tracking outbound links to our social medial pages … we wanted to see how many people ended up on our facebook page through what specific ads and promotions.

Both of these require a little manual effort – you have to create specific links to gather specific data.

For the first — Google calls this CAMPAIGN tracking. As in—an ad campaign.  Makes sense :)

There are three things I’m keeping track of with this:

  • Campaign Source (utm_source): to identify a search engine, newsletter name, or other source where your ad is going to be seen (if you have an ad in an email – you’d put the name of email here)
  • Campaign Medium (utm_medium): to identify a medium such as email or cost-per- click. What type of ad is it? Banner ad, text link, or a link from an e-mail?
  • Campaign Name (utm_campaign): to identify a specific product promotion or strategic campaign. What promotion is this ad part of? Free shipping?

You can use Google’s URL builder here – or of course you can manually create your links. Once you know the format – it’s just as easy to do your own.

So for instance, let’s say I had an ad for football tickets that I placed in an email newsletter.  The URL to the event was:

a href=”http://www.mydomain.com/sportingevent.html”

In order to track the data for that specific URL –  I would change that link used in the email newsletter to be something like this:

a href=”http://www.mydomain.com/sportingevent.html?utm_source=july2009newsletter&utm_medium=email&utm_campaign=VUfootball09262009″

To view your analytics for these links:

  1. Login to Google Analytics
  2. In the left side-bar, select Traffic Sources.
  3. Then click on Campaigns.
  4. Select the Campaign Name you want to track. This is the Campaign Name you designated when tagging the ad URL above.

For the second – tracking our outbound links, we’re going to do a little javascript-ery-trickery to get what we want.

Without this – it’s pretty much impossible to track how people are getting to our social media sites. Those sites don’t live on our servers – so we can’t put the GA code on them.  We could track how many people click on a link on a specific page on our servers – but that gets kind of clunky tracking-wise.

So – what’s the best way to track which external links are popular with your site visitors?

(There is a javascript “addon” that will track this information (available here) — it will track external links and file downloads. Simply install the code right above the GA code on all your pages – and wala. You don’t have to manually edit each link.)

Here is how I prefer to track this information.

Our link starts out like this:

a href=”http://www.externalwebsiteurl.com/”

To track it … we’ll turn it into this:

a href=”http://www.externalwebsiteurl.com” onClick=”javascript: pageTracker._trackPageview(‘/outgoing/externalwebsiteurl.com‘);”

(you could make outgoing anything you want … but decide on a standard so that you can easily pull this data)

View the number of clicks to the externalwebsiteurl.com from your own website by

  1. Login to Google Analytics
  2. In the left side-bar, select Content.
  3. filter the urls by putting “outgoing” in the filter box.
  4. You’ll see the data for your tagged outgoing links here!

You could also use this for tracking file downloads.  Just change the /outgoing/ part to /downloads/ or something.

original url:

a href=”http://www.mydomain.com/assets/How-To-Waggle.pdf”

altered, google analytics tracking url:

a href=”http://www.mydomain.com/assets/How-To-Waggle.pdf” onClick=”javascript: pageTracker._trackPageview(’/downloads/WaggleHowTo’);”