Introduction:
When using the SharedCount API, you might encounter data discrepancies due to how URLs are structured. This guide helps you understand URL canonicalization and how it affects share counts, particularly when working with multiple URL versions or shortened URLs.
Why Discrepancies Occur
SharedCount gathers data directly from Facebook, including private profiles and public shares. However, different URL structures can yield varied results, even for the same content. This happens due to differences in protocol (HTTP vs. HTTPS), the use of “www.”, and the presence of trailing slashes.
You may check Facebook Debugger to verify that Sharedbook's results are correct.
Canonical URLs
There are multiple reasons why you may receive different results when querying URLs. Small variations in URL structure can lead to discrepancies. Pay attention to these factors:
• Protocol: http:// vs. https://
• Subdomain: with or without www.
• Trailing Slash: URLs with or without a / at the end
This creates 8 possible variations of a single URL, each potentially returning different data:
• http://www.sharedcount.com
• http://sharedcount.com
• http://sharedcount.com/
• http://www.sharedcount.com/
• https://www.sharedcount.com
• https://sharedcount.com
• https://sharedcount.com/
• https://www.sharedcount.com/
Canonicalization is the process of selecting the best version of a URL when multiple options exist. For example, www.example.com and example.com/index.html are technically different URLs, but Facebook canonicalizes to the most representative one.
Handling Shortened or Redirected URLs
When dealing with URLs shortened by services like Bitly.com or redirected URLs, these are treated similarly to canonical URLs. The share count is attributed to the destination URL. You can verify this behavior using the Facebook Debugger.
For example, if you shorten https://www.sharedcount.com to https://bit.ly/3CHfW49, Facebook will resolve the short URL to its final destination, https://www.sharedcount.com, and display the share count for the original URL.
Sharing a shortened URL such as bitly.com will increase the shared count of the canonical URL.
Here is a demonstration:
Examples
Canonical URL Tag Set
Example URL:
It looks like the Canonical URL is set to the following URL:
Therefore, it's returning the share count for the canonical URL, rather than:
To return the data you are looking, the website should fix the canonical URL issue.
Either:
Remove this canonical URL meta tag
Or set it to the current page, ie. https://ec.europa.eu/commission/presscorner/detail/en/mex_23_2784
Important things to note
A small percentage of URLs don't return accurate results with Facebook. That's because Facebook normalizes shares for pages that declare a canonical URL, either with OpenGraph URL or canonical URL meta tags. That means they'll aggregate the shares across all those URLs that share a canonicalized URL. For URLs where these canonical URLs are set incorrectly or inconsistently, the data you'll get for those URLs and their shares will be limited.