How To Do Event Tracking In ActiveCampaign on WordPress
ActiveCampaign is a very impressive marketing automation software that is going from strength to strength.
They are very active in developing new features. Often with multiple updates and additions to the software each week.
And for the most part they are one of the more user-friendly options out there.
The majority of features work straight out of the box…
…however event tracking isn’t one of them. It requires custom coding and is definitely one of their harder features to implement.
In this post I’ll show you how to implement event tracking for ActiveCampaign on WordPress (including a free custom WordPress plugin I had developed).
Free Plugin: Download the free ActiveCampaign Event Tracking plugin that is explained in this post.
What Is Event Tracking
Every good marketing automation software should allow you to track how your users are interacting with your website.
ActiveCampaign does this with a combination of site tracking and event tracking.
Site tracking is a bit of code similar to Google Analytics where you place some code on every page of your site.
This code tracks what pages people visit and once ActiveCampaign knows who someone is (because they opt-in, login, visit a link from your email etc), then it will automatically show that information in the contacts record.
It’s great to know which pages people visited. This can be useful to see what topics someone is interested in, useful for lead scoring, it can even be used to start automations for something like cart abandonment automations.
But what if you wanted to know more?
Site tracking will show you WHICH pages your contacts are visiting, but it doesn’t show you WHAT they are doing on those pages.
Sometimes there are specific actions you want to track. Often this is clicking on certain buttons or links. For example to download a resource, or click to visit a certain page off of your site.
That’s where event tracking comes in.
Event Tracking Examples
A great overview of event tracking is on the ActiveCampaign website.
Some practical examples of where you might want to use event tracking are…
Started A Form But Didn’t Finish It
Maybe you have a form where you need to capture some information (like a quiz, for a consultation, or a feedback request form). It would be useful to know if someone started the form but didn’t finish it.
With event tracking you can track if someone clicks to start the form but doesn’t make it to the end and start an automation to encourage them to finish it.
Downloaded a Resource
Or maybe you offer some sort of lead magnet as an opt-in but you want to have different paths for people that clicked to download it and those that didn’t.
After someone opts-in you send them to the download page and want to track if they actually click to download your lead-magnet. With event tracking you can.
As Part of Lead Scoring
You could also use it as part of your lead scoring setup. You could track clicks on things like share buttons as an event.
Every time someone clicks a share button you could increase their score.
How It Works
For event tracking to work we need a couple of things:
- Know WHO the person is
- Track and record WHAT specific action they take
- Send both the WHO and the WHAT to ActiveCampaign via their API
Step 1 – Know Who Someone Is
There are a few ways we can know who someone is. Ideally if people login to your site (such as a membership site) you can know who they are.
That’s useful if you have a membership area. But even then it doesn’t help with people that have just become leads. In this case the two main ways we can know who some is are when they:
- Provide you with their email (like opting-in for your lead magnet)
- Follow a link in an email you send them
Whenever we have the opportunity to verify who someone is we want to store this information in a cookie. By doing this, the next time they visit your site on the same browser we will know who they are and can use that data for event tracking.
To achieve this always append a URL with the contact’s email address when you have it (like straight after they opt-in or follow a link in your emails). For example:
[html]http://www.yoursite.com/[email protected][/html]We then use some code to get their email from the URL and store it in a cookie:
Note – you can modify this code to use a different variable name if “email” conflicts with something you are already using.
Step 2 – Track and Record Events
There are a number of events you can track depending on your use case. For this plugin we are going to track any HTML DOM events.
We use some javascript code with the AJAX onreadystatechange event. The code to do this is in the attached plugin.
Free Plugin: Download the free ActiveCampaign Event Tracking plugin that is explained in this post.
Then all you need to do is modify the specific elements you want to track by adding the event name and “ac_event(‘Event Name’, ‘Event Value’);”. For example:
You will want to use your own event names and event values as this is what will be recorded in ActiveCampaign. Here is where it will show up:
Step 3 – Send The Who and The What To ActiveCampaign
The final step is to combine the event that has been tracked with the user information (their email) and send both pieces of information to ActiveCampaign.
To do this we check to see if the users email is stored in the cookie and if it is we send this along with the event data to ActiveCampaign.
This plugin makes use of the ActiveCampaign PHP wrapper and event tracking via the API.
You will need to update the activecampaign.php file in the plugin folder with your API details:
- Login to ActiveCampaign
- Under your name in the top right go to My Settings > Developer
- Copy the value of the “URL” field to the AC_URL constant in the script
- Copy the value of the “Key” field to the AC_API_KEY constant in the script
- Go to My Settings > Tracking > Event Tracking
- Enable event tracking with the “Status” toggle
- Copy the value of the “Event Key” field to the AC_EVENT_KEY constant in the script
- Create the necessary event names under “Events”
- Under “Events”, click on the link where it says “Event Tracking API”
- Copy the value of “actid” to the AC_ACTION_ID constant in the script
This is how it should look once you are done (these are just example values not real values):
How To Put This Into Action
I have included a description of how this particular event tracking implementation works. I think it is important to understand what is happening before you go and start adding random things to your site.
With that said, here is a summary of steps to implement it for your site:
- Download the ActiveCampaign Event Tracking Plugin
- Modify the activecampaign.php file as per the details above
- Upload the plugin to your WordPress site and activate it
- Add or update any HTML DOM events you wish to track using this format:
[html]domevent=”ac_event(‘Event Name’,’Event Value’);”[/html]
Testing
To make sure everything is working, first check that an email is being stored in a cookie.
Visit your website and append a test email that is already in ActiveCampaign.
Next view the cookie information stored in your browser (see details here).
You should see the test email stored. Here is a screenshot from Chrome:
And a screenshot from Firefox:
Next make sure you have something set with your DOM event (for testing I find a link to be easiest).
Now in the same browser where you just set the test email address in the cookie visit the page with your updated link (or other event), click on the link (or whatever action you setup).
The first check is to make sure you get a message in the Console of your browser. To access the console, right-click on your webpage and select “Inspect” or “Inspect Element” and then click on the “Console” tab. You should see a message like this in Chrome:
And this in Firefox:
If that all checks out okay then go ahead and check in ActiveCampaign under the test contact’s record. You should see the event is recorded in the “Site and Event Tracking” section. See the screenshot below for an example:
You can now use this in automations and for segmentation.
Important Note
I want to be clear that I paid to have this plugin developed for my own personal use, my private clients and members of my community.
I am providing a version here for free. However no guarantees it is the latest version.
If you want to make sure you get the latest version plus on-going support (and a WHOLE lot more) you can do that here.
Click here to download the plugin