WpCode.net

Daily Wordpress Code Snippet

How to integrate Goo.gl Analytics in WordPress

| 0 comments

Pin It

This article explain how to integrate goo.gl analytics in a new column of your Dashboard. This code uses the goo.gl api to show the click informations.

Add this code in your function.php file. Before you use this code You need to integrate goo.gl in your blog Continue reading

To know how to integrate goo.gl in wordpress read this tutorial

function googl_post_columns($columns)
{
	$columns['shortlink'] = 'Shortlink';
	return $columns;
}

function googl_custom_columns($column)
{
	global $post;
	if ('shortlink' == $column)
	{
		$shorturl = wp_get_shortlink();
		$shorturl_caption = str_replace('http://', '', $shorturl);
		$shorturl_info = str_replace('goo.gl/', 'goo.gl/info/', $shorturl);
		echo "<a href="{$shorturl}">{$shorturl_caption}</a> (<a href="{$shorturl_info}">info</a>)";
	}
}

add_action('manage_posts_custom_column', 'googl_custom_columns');
add_filter('manage_edit-post_columns', 'googl_post_columns');

Via Kovshenin.com

Leave a Reply

Required fields are marked *.

*