How to run BuySellAds over SSL in WordPress

buysellads.com

While they haven’t made an official announcement yet, BuySellads (finally) supports running their ads over SSL. For the longest time, I waited to switch Do It With WordPress over to HTTPS because I couldn’t run the ads over HTTPS, so any time a page with ads was loaded, the page was no longer fully secure and would provide a “mixed content” warning, meaning that some of the page’s assets (the ads in this case) were not running over a secure connection. Not a very good end user experience.

However, now that BuySellAds supports running over HTTPS, here’s what you need to do to implement it on your site.

In the installation instructions that BuySellAds provides to you, they’ll tell you to add a snippet of code right after the <body> tag. The snippet looks something like this:

(As a side note, please don’t actually add this to your theme files below the <body> tag – you should enqueue the Javascript instead.)

In line 7, you’ll see an HTTP reference (http://s3.buysellads.com/ac/bsa.js). This is the offending problem. You could just upgrade this to HTTPS, but the best thing to do is make it protocol-agnostic. This means that if it’s being loaded on an HTTP page, then it will load the HTTP version, but if the page is HTTPS, then it will load the HTTPS version. To do that, simply remove the http: altogether, which will make it look like this:

And that’s all there is to it. You can now run your ads (and your whole site) over SSL. I’m sure an official announcement is in the works from BuySellAds once they’ve finished user testing and updated all of their documentation, but there’s nothing stopping you from doing this today.

One thought on “How to run BuySellAds over SSL in WordPress”

  1. paulbraren says:

    Back on March 22 2015, I move my site to https, and spotted your article that got me going with BSA again. Thank you, fixing that was a big deal, and very important.

    On March 24th, I reached out to BSA support, and by April 8th, they put together a public post with the good news:
    http://support.buysellads.com/knowledge_base/topics/does-your-ad-code-work-in-https-pages?from_search=true

    Thanks Dave!

Leave a Reply