Skip to main contentSkip to footer

Relevanssi Premium 2.16 introduced a new feature of click tracking. It allows you to see the effectiveness of the search, which links the users click from the search results, and which search terms are most effective for each post.

The tracking allows you to find which posts receive clicks from low rankings. You can then boost these posts higher up in the rankings to make them easier to find. You can also see where keywords result in clicks on too many posts — more focus may be necessary there.

How to use

To use click tracking, enable it on the Relevanssi Logging settings page. You also need to enable regular search logging. With the click tracking active, the User searches page will show you clicks to the posts. The Relevanssi sidebar on post edit pages will also show you more information.

You can see “Click tracking insights” on the User searches page. This view will show you the posts with the most clicks, the posts with low-ranking clicks and the queries with the most posts. You can click each post and query to see more information.

How it works

Click tracking works by adding extra parameters to the search result links. When the feature is active, you’ll see two new parameters added to the links: _rt and _rt_nonce. The _rt_nonce is a safeguard to avoid logging clicks many times. The actual data is in the _rt parameter. It contains all the necessary information in an encoded format.

When a link with these parameters gets clicked, Relevanssi saves the click. The click data is in the wp_relevanssi_tracking table. Relevanssi stores each click’s post ID, search query, ranking, and timestamp. The log has no information about the user.

When the user sees the page, Relevanssi removes the click-tracking parameters from the URL. This helps prevent users from distributing the URLs with the click tracking parameters.

Showing the most clicked pages

I’m using this function to create a shortcode that will display the most popular articles:

add_shortcode( 'most_clicked_results', 'most_clicked_results_shortcode' );
function most_clicked_results_shortcode() {
	global $relevanssi_variables, $wpdb;

	$output = get_transient( 'most_clicked_results_shortcode' );
	if ( $output ) {
		return $output;
	}

	$popular_posts = $wpdb->get_results( "SELECT post_id, count(*) AS hits FROM {$relevanssi_variables['tracking_table']} GROUP BY post_id ORDER BY hits DESC LIMIT 6" );
	$post_ids      = wp_list_pluck( $popular_posts, 'post_id' );
	$links         = array();
	foreach ( $post_ids as $id ) {
		$links[] = '<a href="' . get_the_permalink( $id ) . '">' . get_the_title( $id ) . '</a>';
	}

	$links = implode( ' | ', $links );
	$output = '<p class="most_clicked_results_shortcode">Most popular search results: ' . $links . '</p>';

	set_transient( 'most_clicked_results_shortcode', $output, WEEK_IN_SECONDS );
	return $output;
}

The [most_clicked_results] shortcode fetches the six most clicked posts and creates a simple element. The results are cached for a week to avoid excessive database calls.

Permalink Manager Pro

The Permalink Manager Pro plugin removes the Relevanssi click tracking parameters from the permalinks. Here’s how you can restore the tracking parameters:

add_filter( 'permalink_manager_filter_final_post_permalink', 'pm_relevanssi_add_tracking', 999, 3 );

function pm_relevanssi_add_tracking( $permalink, $post, $old_permalink ) {
	global $relevanssi_tracking_permalink;
  
	if ( ! function_exists( 'relevanssi_add_tracking' ) ) {
		return $permalink;
    }

  	if ( isset( $relevanssi_tracking_permalink[ $post->ID ] ) ) {
		unset( $relevanssi_tracking_permalink[ $post->ID ] );
	}

	$permalink = relevanssi_add_tracking( $permalink, $post );

	return $permalink;
}

Problems with permalinks

Sometimes, click tracking may cause problems with permalinks. If you notice broken permalinks on search results pages and disabling the click tracking fixes the problem, you can disable the click tracking permalink cache with this snippet.

add_filter( 'relevanssi_add_highlight_and_tracking', function( $value ) {
  global $relevanssi_tracking_permalink;
  $relevanssi_tracking_permalink = array();
  return $value;
} );

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Target specific part of the post

…specifier for each word separately. Phrases are supported. Examples: Search for word “cat” in titles only: {title:cat} Search for word “dog”, but only in tags: {tag:dog} Search for posts that have the word “knizia” in the taxonomy “designers” and the word “dutrait” in the taxonomy “illustrators”: {designers:knizia} {illustrators:dutrait} Note that…Relevanssi Premium 2.4.4 introduced a new feature where you can target specific parts of the post straight from the search terms. The format for this is {target:search_term} Target can be one of the following: title: Post title. content: Post content. author: Author display name. comment: Comment text. link: Link from……any of these targets only if Relevanssi indexes that particular type of content: if you want to, say, target excerpts, you need to make sure Relevanssi is set to index the excerpt. The search term must be a single word, so if you want to target multiple words, use a…

Relevanssi indexes excluded posts

…use the Relevanssi admin search (Dashboard > Admin search). If you use the admin search and you’re still getting posts from the wrong post type, you can move on to the next step. If the admin search gets you the correct results but your theme front end search doesn’t, your…Sometimes it can happen the search results include posts from a post type that has been excluded from the index. When that happens, here are things you can check. Are you using Relevanssi? It’s possible your search results are not coming from Relevanssi. The quickest way to check is to……theme search is not using Relevanssi for some reason. Common causes for indexing the wrong post types The most common reason for index including the wrong post type is a shortcode or some other feature that displays posts and confuses Relevanssi. In the case that prompted this post, the search

Integrating Post Views Counter stats

…example, I have Kirjavinkit, a book review site with an archive of about 10,000 book review posts. The popularity of the posts is primarily driven by external search traffic and seems like a good indicator of what users find interesting and valuable. Integrating the Post Views Counter stats as a factor…

Related Posts:

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed