Social Connected with Sitecore (Facebook) 3: Post ad hoc messages to facebook

The facebook social connected module only allows your application to post to a user timeline when a goal is triggered.

Your site business logic might need you to make ad hoc posts when certain logic is triggered. While we could definitely achieve the results we want by creating goals for each of these actions, this might not adhere with the marketing guidelines.

So here is how we achieved this functionality using the Facebook js API

<script type="text/javascript" src=""></script>
<script type="text/javascript">
var facebookAppId = '<%=FacebookDefaultAppId %>';
FB.init({ appId: facebookAppId, status: true, cookie: true, xfbml: true });

function openFbPopUp() {
method: 'feed',
name: 'Your Site Name',
caption: ' ',
link: document.URL, // Current Url
description: $('#quotes').html(), 
// Description from the sitecore item which was available in the same page
display: 'popup'
return false;

FacebookDefaultAppId – was the app id (Application Id) set in the sitecore item where we set the facebook app details:


Which we get here in facebook for the app created:

Truth be told, this solution has nothing to do with sitecore, but since we manage the app secret key in sitecore, I am pulling it in from there as opposed to saving it some place else too.

This results in the following when the js is triggered (say on button click):

One thought on “Social Connected with Sitecore (Facebook) 3: Post ad hoc messages to facebook

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s