I'm writing a SPA that uses underscore templating. The app searches for and rates music albums and returns the result via ajax. If facebook open graph metatags cannot be altered dynamically and the url of the page is constant regardless of search result, how can i make it so users can share that they rated a certain album.
ie)
<meta property="fb:app_id" content="118454308341351" />
<meta property="og:url" content="http://www.appurl.com" />
<meta property="og:title" content="Fleetwood Mac's Rumors" />
<meta property="og:image" content="AppImg.jpg" />
and update those properties to reflect a given search result.
The way I handle this is to create a dynamic page which I use as my open graph object, which is simply populated from the url parameters and redirects back to my SPA using the meta redirect.
<meta http-equiv="refresh" content="0;URL=http://YOUR_WEBSITE_WITH_DYNAMIC_CONTENT">
Thanks to this tutorial I found a solution: https://speakerdeck.com/sienatime/facebook-sharing-for-single-page-apps?slide=15
I send only meta tags if the user-agent of the http request includes "facebookexternalhit".
Here is some code for a backend with node and express:
app.get('/', (req,res) => {
if(req.header('user-agent').includes('facebookexternalhit'){
res.send(`
<meta property="og:title" content="The Slits' Cut" />
`);
} else {
res.sendFile(index.html);
}
})
You could also write your own middleware for that.
Our solution was to use Netlify pre-rendering, which pre-renders and then caches the rendered HTML to serve to crawlers and bots specifically.
This seems to work well. It allows us to dynamically update the OG meta tags, which are then cached by Netlify and served to crawlers, so they see the correct content.
It was easy to setup too, so if you are using Netlify this may be a good solution for you.
Related
Running a URL through the Pinterest URL Debugger, and it appears to be caching have old data. Is there a way to force a refresh similar to Facebook's debugger?
I would attempt to clear your browser cache (I'm assuming it's ran in browser).
Maybe it's also using an old cookie, so log out, clear your browser cache/history, then close and open it again. You could also try a different browser to access it.
You could also try changing some old data to see if there is a pinterest db process that's using old data, and an update might refresh it.
Otherwise, you may want to reach out to pinterest support.
OK so it turns out that it was NOT holding on to old information, but rather I was using the incorrect tags for price and currency.
should be og:price:amount and og:price:currency
full documentation for the product type of rich pins: https://developers.pinterest.com/docs/rich-pins/products/
from above, minimum requirements:
<meta property="og:title" content="Name of your product" />
<meta property="og:type" content="product" />
<meta property="og:price:amount" content="1.00" />
<meta property="og:price:currency" content="USD" />
I have one big web app that is basically one page where every content is created dynamically. It also has a forum, how do I expose the forum to Google or other search engines? Should I create a seperate view of the forum especially designed for search engines?
Use meta tag in your html. This metadata can be used by search engines (keywords).
<meta name="description" content="xyz your web site name etc">
<meta name="keywords" content="xyz your web site name etc">
<meta name="author" content="xyz your web site name etc">
I am trying to provide "Like" buttons INSIDE my Facebook app that will allow users to "Like" dynamic content for the purpose of advertising the app.
For this reason, when someone Like's and the post appears on their wall, I need to to say "via [My App Name] and the app's icon at the bottom of the post. However, with my current method, I'm seeing the post perfectly including the link to the external URL, but the App's name is not present.
The app runs by loading index.php from my Canvas URL. Index.php references:
< script src="https://connect.facebook.net/en_US/all.js#xfbml=1">
and $(document).ready does this:
FB.init({
appId : '[my app id]',
status : true,
cookie : true,
xfbml : true
});
then loads the content pages via Ajax into a blank div in the middle of the page.
The page loaded via Ajax contains numerous instances of the following:
< fb:like data-layout="button_count" href="[the url of my dynamic content]">
Then in $(document).ajaxComplete(), I do FB.XFBML.parse();
The dynamic page being linked to has the following tags:
<meta property="og:title" content="my title" />
<meta property="og:description" content="<?=$php_variable?>" />
<meta property="og:type" content="website" />
<meta property="og:url" content="[the url of this page]" />
<meta property="og:site_name" content="site name" />
<meta property="fb:app_id" content="[my app id]" />
Anybody see where I'm going wrong? If I missed posting any critical info, I'll be happy to - I'm just cross-eyed at this point and might have missed something.
Thank you in advance for your help!
The Like button doesn't attribute the like to the app linked to the URL you're liking - there is no 'via' link - adding the app to the page is done so that the app can publish to users that like the page, manage the insights, etc
I've been testing the open graph tags for facebook and I can't get my logo to show when I share my website link on facebook.
If I use the lint debugger (https://developers.facebook.com/tools/debug) I get:
**Open Graph Object Properties**
og:url http://www.movimenting.me/
og:type website
og:title http://www.movimenting.me/
og:updated_time 1318267537
**Raw Open Graph Document Information**
Canonical URL http://www.movimenting.me/
Meta Tag <meta property="fb:app_id" content="210576275672723" />
Meta Tag <meta property="og:image" content="http://www.movimenting.me/images/logo2.jpg" />
Meta Tag <meta property="og:title" content="Movimenting.me" />
Meta Tag <meta property="og:type" content="website" />
Meta Tag <meta property="og:url" content="http://www.movimenting.me" />
Meta Tag <meta property="og:site_name" content="Movimenting.me" />
You can see that it gets the og:image on the raw part, but doesnt on the object properties..
Why is this? I always specify the same URL and opengraph.in gets the right tags..
thanks in advance.
everything comes out clean now on lint:
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.movimenting.me%2F
image, locale, you name it. no errors or warnings or others.
BUT STILL, when you share the link (www.movimenting.me) on facebook, no image apears.
What can I do now, or what should I look for now?
Oh, btw now i recall: if I remove the og:image tag, it will indeed find 30 images to share, but not the logo. It's so strange, since the logo is the first one..
what now?
thanks in advance
Is there any errors in the debugger? Maybe the app_id doesn't match that domain?
Late reply but I've been having the same problem even though Facebook debug would report no issues and finally fixed it.
Nothing would show up when I had a 50x50px image which Facebook didn't complain about in the debugger. I finally changed the image URL to use a 128x128px one. It worked even though Facebook complained that the image should be at least 200x200px which I then used.
You can see the fix working here. https://www.thesuiteq.com
I wanted to know how can I use Facebook Like button on my Ajax web application, that will capture changes in the Open Graph tags for both the og:title and the og:url. I already created a Facebook app and got an API ID.
What I want to know is the code that I need to put on my website in order for Facebook to capture the changes that I've made to the meta tags which contains that title and url information (ie. og:title, og:url).
I followed the instructions on Facebook without success. Furthermore, I want to know how can I locally test the Like button to see that it grabs the data from the Open Graph tags properly.
Also worth mentioning that I've a JQuery code that automatically alters the Open Graph meta tags to include the relevant information for the current Ajax changed page.
Thanks.
You will need to have a separate url for each different page that you want to allow people to like. I would recommend actually pointing the like button to the physical pages you're trying to return via the og:url tag. To refresh the data that Facebook stores about a given url, pass that url into the linter at http://developers.facebook.com/tools/lint.
i created a rotator file for facebook share on my dynamic ajax website.
rotator.asp code sample:
<html>
<% lang=request("lang")
id=request("id")
..some sql to get data...
ogTitle=....
ogImage=....
originalUrl=....
%>
<head>
<meta property="og:title" content="<%=ogTitle%>" />
<meta property="og:image" content="<%=ogImage%>" />
.....
......
<meta http-equiv="refresh" content="0; url=<%=origialUrl%>" />
//dont use redirect.. facebook dont allow 302...
</head>
<body></body>
</html>
for example xxx.com/#!/en/153 page will share xxx.com/rotator.asp?lang=en&id=153