All Collections
API Documentation
Global Optimization
Optimize Organic Shares From Your Website Using Your Best Test Message
Optimize Organic Shares From Your Website Using Your Best Test Message
Apply your best performing creatives to your Open Graph Tags
Naytev Team avatar
Written by Naytev Team
Updated over a week ago

With Naytev's Global Optimization API, you can take the winning content from your test and use it as your Open Graph title, description and image. This ensures that every time a reader shares your content, the message shared is the version proven to drive the most engagement and referral traffic.

Below we provide background information about Open Graph tags, then we provide a simple guide on how to apply the best performing content from your Naytev test to your Open Graph tags. 

A. Open Graph Tags Background Information

Facebook uses the Open Graph Tags protocol to collect information about your webpage, and Facebook uses these Open Graph Tags (metadata) to display your webpage within the Facebook ecosystem. For example, the Open Graph Tags define the way a webpage is displayed in the Facebook News Feed when someone shares it using a share button on that webpage. Here is a sample of the Open Graph Tags for a webpage:

<meta property="og:title" content="A/B Testing Tools Roundup "/>
<meta property="og:url" content="http://blog.naytev.com/testing-tools/"/>
<meta property="og:image" content="http://blog.naytev.com/images/posts/testing-tools/cover.jpg"/>
<meta property="og:type" content="article" />
<meta property="fb:pages" content="1438235733064962" />
<meta property="og:description" content="There are many tools available for A/B testing. Here are the ones you need."/>
<meta property="article:published_time" content="2016-06-02T00:00:00+00:00">

After your webpage is published, you should only update three Open Graph Tags:

  • Title

  • Image

  • Description

Facebook will NOT allow changes to the og:type or other metadata associated with the webpage after it is published.

B. How to Update Your OG Tags to Optimize Organic Shares

Naytev's Global Optimization can be used to automatically apply the best Title, Image, and Description from your team's Naytev message test to your website Open Graph Tags. Doing so optimizes the performance of organic sharing. Below is a guide on how to implement this service.

Please note, the updates described below must be done server-side not client-side.

1. Complete an API Request Using the og:url

On pageview, make an API call to get the result for the piece of content. This example uses one of Naytev's blog posts: http://blog.naytev.com/clickbait-101/. For this article, the og:url is http://s.naytev.com/clickbait-101/, we will use that as the URL of the API request. The request URL will be this: https://api.naytev.com/v1/test/result/http%3A%2F%2Fblog.naytev.com%2Fclickbait-101%2F

@response = HTTParty.get("https://api.naytev.com/v1/test/result/http%3A%2F%2Fblog.naytev.com%2Fclickbait-101%2F", 
                :headers => { "X-Auth-Token" => "THISISMYAPIKEYNOREALLY"})
)

2. Check the Status of the API Response, Update OG Tags

Check the status of the response. If there is a 204 response, then use the default content you would normally use from your CMS.If there is a 200 response, use the following fields in your Open Graph tags:

<meta property="og:title" content="<%= @response.headline %>">
<meta property="og:description" content="<%= @response.description || " " %>">
<meta property="og:image" content="<%= @response.image %>">

3. Make Facebook Rescrape your Content

Just because you update your open graph tags doesn't mean that Facebook is using that information. After you update your Open Graph tags, you must make Facebook re-scrape your webpage to purge Facebook's cache. This can be done through Facebook's API or manually. Below we cover how to programmatically purge Facebook's cache.

You need to notify Facebook when there is a change in the Open Graph Tags for your webpage. When a webpage is changed, you should make a POST request to the object endpoint. The object endpoint contains two parameters:

  • id=${encoded_url}$ - this is the og:url of the webpage

  • rescrape=true - this signifies that Facebook should rescrape the webpage

A sample call looks like this:

@response = HTTParty.post("https://graph.facebook.com/?id=http%3A%2F%2Fblog.naytev.com%2Fclickbait-101%2F&rescrape=true")

Don't rescrape an object more than you need to. Facebook has unpublished limits on the number of times the rescrape should be called. We strongly recommend that you do not rescrape the Open Graph Tags more than once every 30 minutes.

Did this answer your question?