subscribe

You can update this text in your control panel, under Theme Options. Nam massa. Ut tempor augue non sapien lobortis aliquam. Maecenas.

November 30th, 2009

Google Analytics is a very popular tool for tracking visits, pageviews, and lots of other metrics for your website. Here’s a handy little trick which allows you to track any event you want on your site, a click on a specific link for example, and have it integrated into your analytics data.

1) First, make sure you are already using Google Analytics on your site (or the page that you want to track events).

2) Second, add this snippet just below the Google Analytics code:

<script type=”text/javascript”>
function trackEvent(category,url,description) {
try {
pageTracker._trackEvent(category, description, document.location.pathname);
setTimeout(’document.location = “‘ + url + ‘”‘, 100);
} catch(err){}
}
</script>

4) Whenever you want to track something, you need to add a call to trackEvent, for example:

<a onclick=”trackEvent(’Outbound Links’,'http://google.com’,'Google’);return false;” href=”http://google.com”> Google </a>

5) Now log into Google Analytics, click on ‘Content’ -> ‘Event Tracking’ you will be able to see clicks on the above link to Google (you might not see it right away!)

Happy tracking!

-Source

No
Comments

Tags:
, , ,

November 16th, 2009

Here’s the code for integrating Facebook Share with Wordpress (i.e. you want users to be able to post your pages on facebook and you want to control what gets posted).

//Dynamic title

<?php
if (is_front_page()) {
echo ‘<meta name=”title” content=”HOME TITLE” />’;
} else {
echo ‘<meta name=”title” content=”‘;
wp_title(”,true,”);
echo ‘” />’;
}
?>

//Dynamic thumbnail using Press 75 Simple Thumbnail plugin

<?php
if (is_single()) {
if ( p75HasThumbnail($post->ID) ) {
echo ‘<link rel=”image_src” href=”‘;
echo p75GetThumbnail($post->ID, 200, 125);
echo ‘” />’;
}
} else {
echo ‘<link rel=”image_src” href=”URL TO HOME THUMBNAIL“>’;
}
?>

//Dynamic description using post excerpt

<?php if (is_single()):while(have_posts()):the_post();
echo ‘<meta name=”description” content=”‘;
$out_excerpt = str_replace(array(”\r\n”, “\r”, “\n”), “”, get_the_excerpt());
echo apply_filters(’the_excerpt_rss’, $out_excerpt);
echo ‘” />’;
endwhile;
endif;
?>

Happy Facebook sharing!

No
Comments

Tags:
, , ,

November 16th, 2009

Here’s a quick script if you want to just display the excerpt for the meta description. I’m using the All In One SEO plugin, which can automatically generate the meta description, but it will use the entire content as opposed to the excerpt. If you’re using a plugin like Smart Youtube this can be a problem. It’s tempting to just add a meta description tag using the_excerpt within the loop on a single page, but that wouldn’t validate, so add this to your header instead. Enjoy!
<?php if (is_single()):while(have_posts()):the_post();
echo ‘<meta name=”description” content=”‘;
$out_excerpt = str_replace(array(”\r\n”, “\r”, “\n”), “”, get_the_excerpt());
echo apply_filters(’the_excerpt_rss’, $out_excerpt);
echo ‘” />’;
endwhile;
endif;
?>

Thanks to Michele for the snippet

No
Comments

Tags:
, , ,

November 10th, 2009

Assuming you write posts in the HTML view (as opposed to Visual), a quick trick for displaying code in your Wordpress posts is to switch to Visual view, enter the code, and then switch back to HTML view. This will automatically translate the code into non-executable code which will be displayed in your post. Try it out by creating a new post, then switching to Visual view and copy/paste this code:

<link rel=”pingback” href=”<?php bloginfo(’pingback_url’); ?>” />

Then switch back to HTML and you will see all the characters are properly escaped, that’s how I wrote this post.

Happy escaping!

No
Comments

Tags:
,

November 10th, 2009

All-In-One SEO is a great plugin for Wordpress and handles all your SEO needs. However, Facebook requires an additional meta tag which All-In-One doesn’t handle, the meta title tag. However, there is an easy way to add this tag in Wordpress, using the built in function wp_title.

The code looks like this, just add it into your header.php file:

<meta name=”title” content=”<?php wp_title(”,true,”); ?>”>

The only problem is that the homepage will be blank, fix it like this:

<?php
if (is_front_page()) {
echo ‘<meta name=”title” content=”BLOG TITLE” />’;
} else {
echo ‘<meta name=”title” content=”‘;
wp_title(”,true,”);
echo ‘” />’;
}
?>

Here is a link to the full reference for wp_title. Keep in mind this displays the same thing as using the_title within the loop, it doesn’t display the full page title, so if you’re changing the title with All In One SEO for example to include category, blog title, etc. this won’t be reflected here, which isn’t necessarily a bad thing.

Enjoy your titles!

No
Comments

Tags:
, , , ,