How to use Open Graph Protocol


What is Open Graph Protocol and why you need it?

Open graph protocol is a protocol (i.e. set of rules) which is used to integrate any web page into the social graph. For example Facebook can be your social graph or social circle. Once the web page is integrated it behaves like the object of the social graph (facebook) i.e. it has same functionality as a facebook page.

Through open graph protocol you can tell Facebook how your shared contents should be displayed on Facebook. This protocol tells facebook which title, URL, image and description of your blog post/page should be used when your content is shared on facebook.


Open Graph Protocol Meta Tags

To turn your web page into a graph object, you need to use open graph protocol meta tags and the ‘like’ button. Following are examples of such Meta tags:

  1. <meta property=”og:title” content=” “/>
  2. <meta property=”og:type” content=””/>
  3. <meta property=”og:url” content=””/>
  4. <meta property=”og:image” content=””/>
  5. <meta property=”fb:admins” content=””/>
  6. <meta property=”og:site_name” content=””/>
  7. <meta property=”og:description” content=””/>


Easiest way to Implement Open Graph Protocol

If you are using wordpress, you can use wordpress for SEO Plugin by Yoast to add open graph protocol Meta tags on your website.  Once you have added the plugin, follow the steps below:

  1. Go to plugin settings (SEO > Social)
  2. Click on the checkbox ‘Add Open Graph Meta Data’
  3. Click on ‘Add Facebook Admin Button’
  4. Click on ‘Save Settings’ button.


Manually Implementing Open Graph Protocol

If you don’t use wordpress or you want to add these Meta tags manually then follow the steps below:

Step-1: Create a Facebook Page or Facebook Application and then claim your domain by associating it with Facebook Page/App. In this way you can use Facebook Page/App insight.

Step-2: Note down the value of the application ID if you have created Facebook App. Otherwise just note down the value of Facebook Admin ID which you can determine from your Facebook Insight Page.

Step-3: Open your theme’s header file (generally header.php) and add following code just before the <head> tag on your web page:


Step-4: Copy-paste the following code at the bottom of your functions.php file and upload it to the server. This code will get the first image from the post and display it.


Step-5: Add following open graph protocol meta tags in the head section (<head>…</head>) of your header.php page:

Tweet to get the code


Replace ‘your_fb_admin_id’ with your Facebook Admin ID.

Note: og:type means type of the object. Since our object is a piece of content (article, blog post, video, photo etc) I have used ‘article’ as object type. You can see the complete list of supported object types here.

Once you have added your special meta tags, you can now add the ‘Facebook like’ button code into the body section (<body>..</body>) of your web pages. You can get the ‘like’ button code from here.

You can either add the HTML 5 code or XFBML (Extensible facebook markup language) code to add ‘like’ button to your web page. Through ‘like’ button, facebook users can share your web page contents with other facebook users.

If a facebook user (who ‘liked’ you content) happens to be your friend and you are already logged into the facebook, then the like button will display the name and photo of that friend.

 If you are logged out of facebook, then the ‘like’ button will look like this:

Step-7: Test your open graph meta tags here:

That’s it. You have successfully used the open graph protocol :)


Example of a web page which uses the open graph protocol


Other Posts you may find useful:

Subscribe to my blog
Join my free newsletter and learn to avoid the analytics mistakes everyone seems to be making over and over again.




About the Author:

Please feel free to endorse/forward my LinkedIn Profile to your clients, colleagues, friends and others you feel would benefit from PPC, Web Analytics or Conversion Optimization.

For any question/comment Contact me