Collecting ActiveCampaign Subscriber Traffic Source Data

On my way to learning JavaScript, I’ve been alternating between tutorials and small projects. I try to pick projects that will stretch my skills without being so ambitious that I end up giving up or have to learn five new technologies just to get them working.

I use ActiveCampaign to handle the email marketing and marketing automation1 for my newsletter and the Chicago Film List and one thing that I’ve always wanted is to be able to see where my subscribers come from.

The goal tracking within the platform is geared towards tracking existing subscribers along a conversion path, but in my case, the main conversion is just signing up for the list. My goal right now is to build an audience and send them interesting newsletters, not to sell anything.

So I decided to code up my own solution with a simple JavaScript file that stores a cookie whenever a visitor visits a site.

Then, if the visitor submits a subscription form, the code updates the values on hidden form fields with the traffic source information that was stored in the session cookie.

When a visitor submits a subscription form, the data gets passed to custom fields in ActiveCampaign and now I can use that information to tag, segment, and personalize my communications (e.g. sending a customized follow up to subscribers that found The Chicago Film List via Twitter so I can ask them to share the site on Twitter).

I wrote the initial solution on Thursday, then my brother (a much more experienced developer) updated it so it doesn’t require jQuery.

And yesterday I added some logic to handle traffic that isn’t tagged with UTM parameters in the URL query string.

I find that a lot of tracking platforms tend to rely on UTMs for their source attribution and honestly, I think that’s way too limited — if you’re just viewing all of your non-UTM traffic as ‘other’, then you’re losing a lot of information.

I want to at least differentiate between referral traffic (with the referral source) and organic traffic.

The main thing I had to learn to implement this was how to work with cookies, which I found to be surprisingly easy and was able to get everything I needed from a few Google searches.

To handle non-UTM traffic, I wrote some logic that tests `document.referrer` to see if the referrer containted google || yahoo || bing || duckduckgo || baidu and then tagged that as organic.

For referrals that didn’t match one of the big search enginges, I tagged it as medium=referral and brought in the `document.referrer` as the traffic source.

And you can hack it to tag traffic from facebook || twitter || reddit || etc. as medium=social.

The file and installation instructions are on GitHub: ActiveCampaign-UTM-Subscription-Source.

  1. They’re also my former employer