October 21, 2015

How to Recommend Related Content in Just Three Lines of Code

Recommendation engines are all over the web – you’ll recognize them under the headings such as “More articles like this,” Amazon’s “Customers Who Bought This Item Also Bought,” or even the side bar of related videos on YouTube. Recommender systems help users discover content on your site that they might not have found otherwise and provide a powerful alternative to a search function.

Now you can bring recommendations to your site by harnessing Algorithmia Recommends, a content recommendation tool to suggest more of your own content and increase user engagement. Best of all? Anyone can do it with just three lines of code!

How Simple Is It?

Just plop these three lines of code into your website’s markup, insert your API key, and Algorithmia takes care of the rest.

The Code

[code]<div class="algorithmia-recommends"></div>
<link rel="stylesheet" href="//algorithmia.com/assets/stylesheets/recommends.css">
<script src="//algorithmia.com/assets/javascripts/algorithmia-recommends.js" data-apikey="YOUR_API_KEY_HERE" data-uuid="82990285-9714-6349-c8ee-859414df1692data-timelimit-months=24></script>[/code]

The above code is what you need to put Algorithmia Recommends on any site. The first line is the container, which the recommendations will render into, followed by a CSS stylesheet we’ve included to give it a nice layout. The last line includes the Algorithmia Recommends JavaScript in your page, and gives you a place to put your API key, as well as options for time-limiting the recommendations and a UUID field so that you can specify which pages are in-scope of the recommender.

Give it a try by pasting the code into your markup and replacing the API key, which you can get by signing up here. The first time the recommender is called it will take a few minutes as it crawls your site, and runs the algorithms. After that one-time process recommendations will be nearly instant.

Using WordPress or Drupal?

We’ve got plugins for both (WordPress, Drupal) to make the integration of Algorithmia Recommends even easier!

How The Recommender Works

Algorithmia Recommends uses the Breadth First Site Map web crawler algorithm and powerful natural language processing algorithms Keywords For Document Set and Keyword Set Similarity to find and categorize all the pages on your website in order to help your users find content that’s most relevant to their interests. Implementing a recommender on your site can increase engagement by helping users browse through content that already exists and encouraging them to stay longer on your site.

In addition to being able to specify a freshness constraint so that your users see recently published content, you can even filter out pages that are irrelevant, such as the homepage, about pages, or terms of service. The generated HTML and included CSS are customizable to fit in with your current design.

Try it today with just a few minutes of set up and head on over to the Algorithmia Recommends page to learn more about this powerful, easy-to-use tool!

Matt Kiser

Matt Kiser

More Posts

Here's 50,000 credits
on us.

Algorithmia AI Cloud is built to scale. You write the code and compose the workflow. We take care of the rest.

Sign Up