The UTM parameters are stored in a cookie when the visitor first arrives at the site. Then, hidden fields in the ActiveCampaign form are populated with the UTM values. When the form is submitted, those values are sent to ActiveCampaign and stored in custom fields.
If no UTM parameters are included in the URL, then the script will consider referrals from Google, Yahoo, Bing, DuckDuckGo, or Baidu as organic traffic.
Referrals from other domains will be counted as normal referral traffic and the source will be set to wherever the visitor came from.
Direct traffic will default all UTM values to
Installation and Setup
- Create custom hidden fields in ActiveCampaign. You can name them whatever you want, but it's easiest if you give them descriptive names and create them in this order:
- UTM Subscription Medium
- UTM Subscription Source
- UTM Subscription Campaign
- UTM Subscription Content
- UTM Subscription Term
Update your list subscription form by adding the hidden fields to the bottom of your form, in the order that you created them.
If you use the Full Embed option for embedding your form, you will have to update the form code on your website. If you use the Simple Embed method, then no change to your form code is necessary.
Before installing ac-cookie.js, you will have to modify it slightly. Look at your hidden form
<input>fields and see what number they are, for example:
[name="field". Go to the bottom of ac-cookie.js and edit the field numbers in the code so they match the field numbers on your form.
Upload the ac-utm-cookie.js file to your server and add it betwween the
<head>tags of your site:
Test it out by visiting your site with test UTM parameters (example.com/?utm_source=test-source&utm_medium=test-medium&utm_term=the-term&utm_content=some-content&utm_campaign=the_big_campaign).
Visit a few pages, then subscribe to your list with a test email. Check the new contact record that was just created and confirm that the fields were populated correctly.
- This should work whether you are using a Simple Embed or a Full Embed of the ActiveCampaign form.
- With a Simple Embed, you will have to open up the embedded JS file to find the hidden field numbers (e.g.
- Support for initial visit UTMs in addition to subscribe event session UTMs.
Distributed under the MIT license.