Quick Campaign Conversion Tracking in WooCommerce

My company hired a marketing firm that is starting our Constant Contact campaigns amongst other things.  We want to track conversions and at this point we don’t need anything too fancy.  Between that, Facebook ads/posts, Google Analytics and our affiliates, there’s a lot of pixels, JavaScript and php functions that need to be added to our system.  It’s a bit overwhelming and each has its own installation instructions/methods.

Right now, we just want to see conversions.  We want to know what source provide how many purchases and at what value.

I searched for some quick methods and plugins that might help but again, too much complicated setup for simple conversion tracking.  So I built a thing.

Quick Tracking Conversions for WooCommerce

I envisioned a super simple system where you can take on a code to the end of a link and all visits to your site with that code would be tracked and recorded when converted.  I wanted to start with simply recorded full, purchase conversions.

I didn’t want to have to setup a campaign with a code and details in an admin before generating links.  I want to just tell our marketing person put something like ?tracking_code=MyEmailCampaign on the end of all links in a Constant Contact.

So I built a plugin.  It’s light weight, secure and solid.  It does it’s job and it does it right.  You add whatever campaign code you want to links for Facebook, Email blasts, affiliates or anything at all that you want to track conversions from a link.  Here’s an example link that could be in an email:

https://example.com/product/t-shirts?qtc_woo_tracking_code=Oct2016-email-blast

After the email goes out and orders come in I can simply go to the admin page of the plugin, type in Oct2016-email-blast and submit the form.  It will show me number of conversions and total money generated so far.

How It Works

The plugin checks for $_GET[‘qtc_woo_tracking_code’] and sets its value in a cookie.  If the user converts it adds a post_meta to the order for that tracking code.

This allows me to pull all details of every order made.  We can get products purchases, shipping methods, totals, taxes and everything.

Here’s the repo if you want to check it out.  It’s simple right now and has Google Analytics Enhanced Ecommerce option you can enable as well.  There’s room to add all sorts of conversions such as product viewing, add to cart and so on.  This plugin will grow.

https://github.com/ChrisFlannagan/woo-flanny-conversion-tracker

3 thoughts on “Quick Campaign Conversion Tracking in WooCommerce”

  1. QQ: I’m not familiar with Woo Commerce, but this piques my interest since I’m working on a very similar challenge for digital ads and emails. Below is the code i implemented to solve for my issue: we have people come to our site from DigAds which have different params – usually UTM but not in this case so I created a standard param we’ll use (I like UTM better but got shot down.) We want to be able to pass it through several clicks, sometimes to off-domain pages. In this case, we pass the campaignID to the landing page where one of the CTAs is a generic Contact Us and we want to track conversions.

    function getUrlParameter(sParam) //I didn’t write this BS, I’m stuck with crap code from a crap dev team
    {
    sPageURL=window.location.search.substring(1);
    var sURLVariables = sPageURL.split(‘&’);
    for (var i = 0; i < sURLVariables.length; i++)
    {
    var sParameterName = sURLVariables[i].split('=');
    if (sParameterName[0] == sParam)
    {

    return sParameterName[1];
    }
    }

    return "";
    }

    var campaignID = getUrlParameter('campaignID');
    var link = '/en/about_us/contact_us?campaignID='+campaignID;

    $(document).ready(function(){
    $("a[href='/en/about_us/contact_us']").attr('href', link); //I'm not using an ID because in the real world example I wrote this for there's no ID on the
    });

    This grabs the campaignID param off the URL and appends it to any link I want. I supposed I could store it as a cookie and then utilize it when I’m referring to an off-domain link.

    1. I like this and there’s a lot to be said about handling this on the browser side of things. Thanks for the comment, very useful!

Leave a Reply

Your email address will not be published.