Wouldn’t it be great if you could send website event data to ActiveCampaign?
Using Google Tag Manager and a little Apps Script I put together, we can make it work.
So here’s what we will cover in this guide:
- Why do we need event tracking in ActiveCampaign?
- How to Send Event Data to ActiveCampaign
- Using Web App URL to Fire GTM Events
- Sending Dynamic Data to ActiveCampaign Using GTM
- Ways to Use this Event Data
In this guide, I’m going to show you how to send over dynamic event tracking data to ActiveCampaign with the help of Google Tag Manager and this Google Apps Script.
Why Do We Need Event Tracking in ActiveCampaign?
ActiveCampaign is already a powerful tool for your marketing analytics. But adding event tracking data makes our email campaign data even more useful!
Event tracking can tell you if your marketing campaigns are working and what campaigns are turning the most conversions.
In other words, it lets you double down on successful marketing approaches and stop wasting time on ineffective tactics.
But without a native JavaScript API available between ActiveCampaign and GTM, it’s hard to get a good idea of how well your campaigns are performing.
With the special Apps Script that I wrote, you can track events in your ActiveCampaign emails with GTM to measure campaign success and boost conversions.
If you’ve been asking questions like: Which campaign elements are most effective with my audiences? How should I tailor my marketing campaigns to maximize conversions?
You’ll find these answers when you start to track events into ActiveCampaign.
And finally, when things look great, you can give yourself a pat on the back (or show successful reports to your employer or clients)!
How to Send Event Data to ActiveCampaign
How do you get the GTM event data that you’ve tracked on your website back into ActiveCampaign?
This is the challenge that has prevented successful marketing analytics in the past. If you’re familiar with code, you’ll immediately see the problem. But if not, let me explain.
You can only implement ActiveCampaign’s event tracking API through the back-end of your site.
This is because it’s written for server-side communication between your website and ActiveCampaign that use languages like PHP or Ruby.
But Google Tag Manager… is completely based on JavaScript. Awkward.
Given this, we really don’t want to expose our API key with server requests between our website and ActiveCampaign.
The solution?
We’ll use a proxy API as a medium between servers.
If that sounds complicated, it’s not—because I’ve built a proxy for you using Google Apps Script.
Using Proxy Via Google App Script
This is where the magic happens!
Firstly, we will send the request to our Apps Script. The script will populate our API keys, then send it to the ActiveCampaign event tracking API.
For this, all you need is to complete two easy steps. Copy our pre-made Apps Script.
Then, configure your copy to your ActiveCampaign account by adding two parameters: api_key and actid.
If you don’t know what these are, we can find these parameters in our ActiveCampaign account!
Setting Up Event Tracking in ActiveCampaign
Secondly, we will configure the tracking in ActiveCampaign. If you hover over your profile in the top right corner, you can configure your AC for event tracking in My Settings.
Select Tracking from the sidebar menu to see two tracking options: Site Tracking and Event Tracking.
Site Tracking is a slightly more basic tracking option. If you turn it on, you’ll get a code for pageview tracking that you can use in Google Tag Manager. Which is fine, but not really optimal.
We’re more interested in the second option, Event Tracking. This option is highly customizable and lets us send data dynamically to our account with the help of Google Tag Manager.
So let’s activate the Event Tracking option.
Next, we will define some events so that we can send custom data to ActiveCampaign through these events.
Also, this is where you will find the Event Key (api_key in the Apps Script) and actid. Let’s copy these parameters and update them in the Script.
Once that is done, click on the save button.
Next, we just publish the script so that it can act as our API proxy.
You will see a dialog box on your screen.
The only thing you need to change on it is Who has access to the app.
Select Anyone, even anonymous from the options.
Finally, click on the Deploy button.
Google will ask you to review some permissions, so just click through and confirm the account that you want to authorize to deploy the script.
This will connect your Google account to external services.
Once you finish this, you’ll be given a link for your Current web app URL.
Now we’ve got a web app that can function as our API proxy but it needs one more element to properly track our GTM events in ActiveCampaign.
This brings us to our next step: adding a query string.
Providing Query Strings to Web App URL
Query strings are the key-value pairs that come after a question mark (?) in a URL.
For example, keys that you might use in query strings for ActiveCampaign include email, event, and eventdata. Values for these keys can be the email address to which the event is sent, the clicked event, and any data that is sent with the event.
So we will simply paste the Web App URL in a browser and add the question mark followed by the key-value pairs.
Let’s press the Enter key. This will give us a success message.
Thus, our event should have been tracked in the ActiveCampaign account.
In the Contacts tab, we will click on the contact to which we sent this.
And we see that a new activity has been tracked.
This activity will be based on the parameter we sent with the query string.
In our example, it is the Clicked event with event data test.
If the event appears next to the targeted contact in ActiveCampaign, then your Apps Script is working correctly!
With our API proxy in place, the next step is to send this data to Google Tag Manager.
But how do we do this? We’ll create a GTM event using this web app URL.
Using Web App URL to Fire GTM Events
Firstly, we will create a Data Layer Variable to fetch the email address of the user and then use a Custom Image Tag to send this email address along with the event to ActiveCampaign.
We will use an outbound link click trigger to attach to our Tag.
Let’s take a look!
Sending Dynamic Data to ActiveCampaign Using GTM
The first step is to build our ActiveCampaign tracking script.
To do this, we need three values:
- the event clicked (which we’ve already defined)
- the clicked URL
- the email address to which we want to attach this
We have three methods to get the email address from the user: using a query string, using a cookie, or by sending the email address to the Data Layer.
In this, we will use my favorite way: sending the email address to the Data Layer. Note that this method would only work if the user is logged in. (So if your site doesn’t have a user login system, you’ll need to use either query strings or cookies instead.)
I have a plugin running that pre-fills the data layer. This gives us the email address of the visitor who is currently logged in.
But how do we pull this information out? We’ll use a data layer variable.
Let’s create a new Data Layer Variable.
We’ll need to enter the exact Data Layer Variable Name for its configuration. And then click on the Save button.
This will dynamically replace the email with the email address of the user who is logged in.
So our variable is now ready!
Next we will build a Tag for outbound link clicks. This Tag will trigger on a URL that needs to get pinged.
So we will create a new Custom Image Tag.
To configure the Tag, add the Current web app URL that we had copied from the Apps Script along with the query parameters.
And because we want to add the email address dynamically, we will replace the email in the query string with our data layer variable {{dlv-email}}.
In the same way we will update the eventdata with the variable {{Click-URL}}.
And the predefined event clicked remains as-is in the query string.
The rest of the settings in Tag Configuration remains the same.
Let’s move ahead and attach the click-outbound link trigger. You can refer to our guide on Outbound Link Click tracking to create this trigger.
Lastly, we’ll Save the Tag and test it out!
If the Tags are fired correctly, we should see our Custom Image Tag fired on all the clicks.
This would mean that the data is sent over to the ActiveCampaign demo account. Obviously the contact to whom you’ve sent the link should be registered within the system for this to happen.
Going to the ActiveCampaign account, you should see all the events registered!
Also, the tracking is dynamic!
How do we know that? The links will change dynamically depending on what we clicked on our page.
Ways to Use Event Data in ActiveCampaign
The event data in ActiveCampaign can actually be used quite dynamically!
You can build automations in ActiveCampaign and segment your data based on the different activities.
For example, I use this data to build my “abandoned cart” email campaign. I also use it to send emails to users when they make progress on my online courses.
In short, this is a great feature to send dynamic information into ActiveCampaign without clogging up all the different Tags and custom fields that you can define within ActiveCampaign.
Summary
So there you have it!
This is how you can send dynamic event tracking data into ActiveCampaign with the help of Google Tag Manager and Google Apps Script.
You can also create automations with this data to build various marketing campaigns.
Do you plan on using this event tracking with ActiveCampaign?
What is your use case?
You can let me know in the comments below!
Hi Team, thanks for the help with event tracking with AC.
In this video, your example assumes the customer is logged, and thus the email is readily available on the page.
However, I want to be able to send event tracking data back to AC once a customer has clicked on a link in our email (not everything we do is for logged in users). Can you help me out?
In this case you would need to tag your links in your email with a parameter (e.g. yoursite.com/landinpage?email=%SUBSCRIBEREMAIL%) Once the user clicks on the link and the Email would be transferred to the actual URL (% % would be replaced with the users email). From there GTM could pick it up with a URL variable and identify the user (but just on that page). If you wanted to have the Email stick around on other pages, you would need to save that data in a cookie.
Thanks Julian,
Is there a way to pass the AC user id instead of the email? That way I don’t have the same privacy issues with placing an email into a cookie.
Also, do you know of a way to apply the personalisation tag to ALL links in AC campaigns? (Like it does with UTM tags)
Thanks again for the help!
Peter.
no, you can’t really use the user id or hash. While it is possible to fill that in the link, the current AC API doesn’t allow to identify the user that way. You need the email address.
That said, a programmer could find a workaround to identify the user later on, but you would need to rewrite the script.
Updating links all at once could be done through the API, but I haven’t tried this myself.
How do you save that data in a cookie? I’m currently running a Funnel built on Clickfunnels and I watched your video above. I have the same question with Peter. This is my funnel. Free eBook > When they submit their info it will be passed by the Native Integration of AC in Clickfunnels (NOT AC FORMS) > They will receive the eBook via Email. I also setup my Site Tracking Code in GTM making a Tag then paste the code in a Custom HTML then create Trigger (All Pages). I tried testing also to send links via AC Campaigns… Read more »
we have another video about how to save data in a cookie with GTM https://www.youtube.com/watch?v=M7_gmzngmQE To be honest, Clickfunnels is far from ideal when it comes to tracking. Sure it’s a great funnel builder software and convenient, but when it comes to tracking it’s a pain to work with. There are workarounds for everything, but I don’t want to recommend them here, as they are far from ideal and you’d need to know the downsides of these techniques. I would therefore recommend to get professional help to implement something like this OR (and this is always a possibility) you change… Read more »
Hi Julian. thank you for this great article. I have a question related to UTM parameters. We work with a vendor who sends traffic to our site via his link. When you click on the link, you’ll be redirected to our landing page. At the end of the URL, there are UTM parameters for “subid” and “uid”. I have already created a tag for the postback with “campaignid={{subid}}&clickid={{uid}}” parameters. What we need to do to capture the values that are passed for those fields when a visitor reaches our site? Thank you!
I don’t quite understand your problem and what it has to do with ActiveCampaign Event Tracking. Can you clarify?
Thanks for the great video.
I seem to be getting my script blocked by the browser (Chrome) and the tag fails to fire.
“Cross-Origin Read Blocking (CORB) blocked cross-origin response ”
I’ve checked and it’s definitely the script that’s getting blocked.
Is this method still working, or have I made an error?
this is news to me. I need to test and see
Hello ! Thank you so muche for this video 🙂
I’m trying to send to send multiple data via eventdata, is it possible ? I would like to send order detail after a bought action,
so I try to send my dataLayer eventdata={{order}}
My datalayer “order” has many info (sku, price, quantity), all is well interpreted in the message of GTM but Active Campaign interprets the infos this way : [object Object]
Can you help me ?
no, not possible
Hi Julian! Can I send video watched and percentage duration to Activecampaign? Please help me with that?
yes, you can. I’d suggest to learn about Google Tag Manager variables
Hi Julian, many thanks for your video. We have this problem in our company: we recently activated Active Campaign and imported our contacts there from WooCommerce (visitors purchase a product and become customers, and so become new AC contacts). We want to track the activity of every new contact in our website, so we can then automate actions -tagging the contacts in their language, sending mail campaigns, etc. This is our web: https://www.au***rt.com/ I followed the steps in your video, cause it looks like the best solution, right? But for us isnt working and I can’t seem to find why.… Read more »
just use the normal site tracking script. No need to use event tracking for what you are trying to achieve.
Thank you, man!
This saved a day!
And I understood, that I should take some GTM course from you 😀 This took too much time for me by creating cookies from form field!
Works like a charm!
Hi Julian!
Thank you so much for this beautiful article.
I follow every step you mention above but i don’t be able to catch the email into data layer of my ecommerce users when they leave their email in a pop-up or after a purchase, or when they sign up on a newsletter form.
My ecommerce is built on Shopify.
I don’t understand if shopify have some limitations or if i am wrong something 😓
May you help me to resolve?
this technique does not capture email addresses. You would need to do this with a different technique (setting a cookie and then reading it later)