Cleaning Up Campaigns with the HTML5 History API – Free WordPress Plugin

It’s been a while since I wrote anything, so I figured I’d dust off the ol’ RSS feed with a free download.

Campaign tagging is essential for marketers, and it’s how a TON of affiliate programs tag referral traffic. It’s also how every email marketing software I’ve ever used works.

When visitors land on your site with campaign parameters attached to the URL – there’s a chance that they could share that URL (with campaign parameters or affiliate IDs!) via social media, SMS, email and chat (here’s a great primer on dark social). It muddies up your analytics when trying to measure campaign effectiveness, and for in-house marketers it can cost you money in extra affiliate referral commissions.



In an attempt to combat all the misattribution, I’m giving out a free WordPress plugin.

Rewrite the story

In modern browsers that support HTML5, you can use the History API to rewrite the URL on the client side so that it displays the canonical URL using replaceState(). Manipulating URLs has a lot benefits when working with JavaScript/parameter heavy sites, as well as sites with infinite scroll. A lot of smart people have discussed the benefits of pushState() and replaceState() before, like Richard BaxterRob Ousbey, and Oli Mason.

I’ve been a WordPress user for 5+ years now, and I knew that a Canonical Rewrite Plugin would be a super easy plugin to make. I had to ask some friends for basic help cobbling it together, but overall it was a breeze. I have it working on my own site now. You can test it out for yourself, or – you can check out this video to see it in action:

Unable to display content. Adobe Flash is required.

(click here to view the video on mobile)

Notice how I click on the Ayima redirect tool and it shows status 200 even though the URL has changed? That’s the Plugin doing its job 🙂

Here’s a look at the code that’s executing this:

jQuery(document).ready(function() { if (canonical = jQuery('link[rel=canonical]').attr('href')) history.replaceState('', '', canonical); });

Here’s how to install the WordPress Plugin from the zip file if you’ve never done it before:

Unable to display content. Adobe Flash is required.

(click here to view on mobile)

Note: Although this Plugin should be fine, there is no telling how the Plugin could interact with the rest of your code base/other Plugins. I highly recommend testing this Plugin on a staging site first. Let me know how it goes for you! Some of you might see a noticeable change in your analytics the next time you launch a campaign!

In order to get this plugin for free, I’m asking for your email. However, I *promise* I will never spam you. If anything, I may follow up to see how the Plugin is working for you.

Download the Free Plugin Here!