1

I'm currently trying to get my Facebook share button to change what it shares depending on the current page. Currently I'm using the meta tags

<meta property="og:image" content="Logo.jpg"/>
<meta property="og:title" content="Little blurb about current page">    
<meta property="og:type" content="website"/>
<meta property="og:description" content="This area should have different content that 
changes with the current page>

And then in my layout.cshtml I have the actual plug in from Facebook

`<span class="fb-like" data-layout="standard" data-action="like" data-show-faces="false" 
  data-share="true"></span>`

Then at the end I poped in some JQuery to get the og tag to change but it's not working...

 $(document).ready(function () {
    var share = $(".value").text();
    $("meta[property='og\\:title']").attr("content", share);
});

I know this is possible, I even have an example of a site doing exactly what I'm trying to do http://elure.co/ (at the bottom of the page)

InFaF7
  • 13
  • 1
  • 5
  • It seems they are using the Add This plug in: http://www.addthis.com/ ...you can have a similar result using Sharrre: http://sharrre.com/#demos – Hackerman Jul 25 '14 at 17:23
  • so they don't use Facebook at all and just bypass it and the og tags? If I use Sharrre how can I make the different tags dynamic? – InFaF7 Jul 25 '14 at 17:26
  • Facebook doesn't execute Javascript when they scrape you. They just download the HTML and look at the og-tags. So you need to make sure that the og-tags are the correct values from the beginning – WizKid Jul 25 '14 at 17:44
  • is there a way to change the og-tags before facebook scrapes so that each page can have different values? I'm currently trying to use the sites that Robert Rozas linked but they aren't working for me – InFaF7 Jul 25 '14 at 17:50

1 Answers1

0

add a data-href attribute with your dynamic link...

<div class="fb-like" data-href="your-dynamic-url" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>
Sabeer
  • 3,940
  • 1
  • 24
  • 20
  • That's the opposite of what I wanted. If I leave out the data-href then it will take the URL of whatever the current page is which is good. My question is how to get the og-title and og-description to change depending on which page I'm on. – InFaF7 Jul 25 '14 at 21:07
  • @InFaF7 this thread may help you ... http://stackoverflow.com/questions/6138780/facebook-share-button-and-custom-text – Sabeer Jul 26 '14 at 04:51
  • That thread was perfect, it pointed me to using FB.ui. Thank you for that! Just curious you wouldn't happen to know how to do this same kind of stuff for linked-in would you? – InFaF7 Jul 28 '14 at 18:02