Monday, 21 August 2017 14:05

Solution for Lost Share Count after Moving to SSL / HTTPS

Written by

I recently switched a client's site from HTTP to HTTPS (SSL encryption) and needed to come up with a solution to their "social sharing counts" resetting to zero.  This is not a flaw or bug, it's working as it was intended.  

Here is how it works.  When you share a page via social media, it uses its URL:
http://www.yoursite.com/the-page-you-are-sharing

When you switch to SSL / HTTPS, your URL changes, similar to if your domain name changes altogether:
https://www.yoursite.com/the-page-you-are-sharing

With the new URL, you lose all of your social sharing counts, a source of major pride (and potential profits).  

My solution (download TXT file) was to write a bit of PHP code that determines whether the article in question was posted before or after my SSL certificate was installed.  Note that this script uses Shareaholic as its example, but you can also adapt it for AddThis or whatever social sharing button service you like.  I saw that Shareaholic Pro accounts, and some premium (paid) share-plugin-developers offer solutions to this problem, but I'm not looking for another ongoing expense.  

I wound up writing my own code for this because other solutions (here, and here) used Javascript in their implementation and didn't seem as solid as my PHP method.  (download TXT file The way my code works is for non-SSL sharing button code section, it includes the 'data-link' command so that you can override the URL of the page being shared.  

In addition to using this code structure for fixing the share counts after adding SSL, you can also use this technique to change domain names, extensions, moving the site into a subdirectory, etc...

Last modified on Thursday, 07 June 2018 15:34

Latest Comments

Got a similar email that seemed suspicious. Ignored it and they even followed up today.
My organization received one of these emails from "Linda," but uses https://www.bestprosintown.com/p...
Hi Nate, I got the same email template from the same email address today and found you through a ...
Just received one today (16 Aug 2022) from "Mailchimp". Thanks for sharing!
Thanks for posting this. I just got one today. I was 99% sure it was a scam, and your post confirmed...


Design & Development

Wordpress, Drupal, Joomla
New custom websites
Bespoke themes and extensions
Redesigns, upgrades, migrations

Web Design & Development


Optimization & SEO

Let us optimize and manage your overall online presence. We offer full service monthly SEO as well as one-time projects.  

Optimization Plans & Pricing


Maintenance, Patching

White glove monthly backups, security updates, maintenance and testing for your Wordpress, Drupal, or Joomla site.

Maintenance Plans & Pricing


Email Newsletter

Bring your web & marketing performance to the next level: monthly blog post roundup via email.  

Stay in Touch!