Raves, rants and reviews
Raves, Rants & Reviews

Home » Gadgets » Lost addthis social share button counts after moving to https

Lost addthis social share button counts after moving to https

So, you finally installed a SSL certificate and moved your website from http to https. Good move! But now all the count numbers on your addthis social sharing buttons have gone back to zero!

Don’t worry, there’s a quick fix thanks to an organic gardener.

Why did the count numbers go back to zero? Because the sharing services are tied to the root of the URL of the page and stores the data recorded for each specific URL.

For instance, http://nrave.com/2010/07/the-wonderful-thing-about-smiling/ actually is a completely different URL than https://nrave.com/2010/07/the-wonderful-thing-about-smiling/.

When you add 301 redirects for all the old http URLs and/or use an Apache redirect code in your htaccess file to redirect http files to https, the sharing service will now recognize the new https address as, well, new and start counting the shares anew.

Let’s get those button count numbers back

To get your old share numbers back you’ll have to instruct the sharing service to go fetch them from the old URLs that they still have in their database. But how to?

After a bit of googling, you’ll discover the solution made by an organic gardener on the super-helpful Stackoverflow at Moved to SSL, lost my social sharing button counts, now need to use the old http url to get them back, which also links to a further explanation on Preserving sharing counts when migrating to https or another domain.

The fixing code

If your blog or site is made with WordPress, simply add the following code in your footer:

<php if="" (strtotime($this-="">item->publish_up) < 1472688000) : ?>
<script type="text/javascript"> 
function buttons(){ 
var kCanonical = document.querySelector("link[rel='canonical']").href; 
window.kCompositeSlug = kCanonical.replace('https://','http://'); 
buttons(); var addthis_share = { url: ''+kCompositeSlug+'' }; </script>
<script type="text/javascript" 
src="https://s7.addthis.com/js/300/addthis_widget.js#pubid=yourownID" async>

Note: remember to replace the “yourownID” with your own addthis ID.

That’s it. This code will now call all the sharing button counts made before September 1, 2016 (Unix Time 1472688000). If you need to change the date, refer to Convert Unix Timestamp.

What’s the catch?

Yes, unfortunately there is a catch.

To get the “old” http sharing count numbers back the above code, you may notice, replaces the referred URL https with http meaning that when people now share the page, its URL will be forwarded as http. Of course, with redirects in place a referred visitor will still land on the right place (your new https page) and your social sharing counter will keep tally.

However, this is not ideal because you’ll still be promoting the http URL while search engines really do like the https URLs much more. In short, it will be better for your site if the search engines could pick up the https version of your page in referral links.

What’s the cure? At this time of writing, addthis does not yet have a decent fix. Frankly, if you can afford the $29 per year fee, the excellent Social Warfare will display your old plus new counts combined on a share button.

In the meantime, if some/all of your pages have really good social share numbers you might like to keep on displaying the http numbers simply because it adds status to the story and because of the lemming affect – the higher the share count number the more likely a visitor will share the page too.

Addthis alternatives

By the way, if you use addthis you really should consider speedier sharing services such as Simple Share Buttons Plus or the mentioned Social Warfare. Or better still, you actually have a good reason not to use social sharing buttons at all.

Can’t see social share buttons on nRave!

Nope, you won’t see it on this particular blog because, to keep things speedy, sharing services and other heavy loading plugins are not used here. (This blog also uses Apache compression, DNS Made Easy, KeyCDN, Cache Enabler caching and the Automattic AMP plugin.) [To view the AMP version of a page, simply add “amp” after the URL, like this: https://nrave.com/2010/07/the-wonderful-thing-about-smiling/amp/.]

The organic gardener

Credit where credit is due. So, thanks very much to Phil Nauta, the Smiling Gardner.

Come to think of it, the fix is so simple it almost reminds one of Peter Sellers as Chance the gardener in the movie Being There.

Happy gardening!

10/10/2016. Category: Gadgets. Topic: .

You may also like -