ActiveCampaign Event Tracking with Google Tag Manager

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:

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.

PHP code to register an event in ActiveCampaign

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.

Apps Script code to read incoming data and push API keys

For this, all you need is to complete two easy steps. Copy our pre-made Apps Script.

Copying the Event Tracking Apps Script to your Google Drive account

Then, configure your copy to your ActiveCampaign account by adding two parameters: api_key and actid.

api_key and actid parameters in the Apps Script code

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.

Activating the Event Tracking option under the Tracking tab of ActiveCampaign

Next, we will define some events so that we can send custom data to ActiveCampaign through these events.

Adding predefined events for Event Tracking in ActiveCampaign

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.

Updating the api_key and actid parameters and saving the Apps Script

Next, we just publish the script so that it can act as our API proxy.

Deploying the Apps Script as a web app

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.

Selecting the option for Who has access to the app setting to deploy the Apps Script

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

Current web app URL generated

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.

Query string after a question mark in the URL

Let’s press the Enter key. This will give us a success message.

Success message for deploying the Apps Script as a web app

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. 

New activity tracked for a contact in ActiveCampaign

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:

  1. the event clicked (which we’ve already defined)
  2. the clicked URL
  3. 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. 

The email address of the visitor who is currently logged in into the data layer

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. 

Entering Data Layer Variable Name and saving the variable in Google Tag Manager

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}}.

Entering the dlv-email data layer variable in the query string of the Image URL

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.

Event and eventdata parameters of the query string in Image URL

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.

Outbound link click event fired on all the clicks on the demo shop page

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.

Clicked events on the contact details of our ActiveCampaign demo account

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.


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!


Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more
Newest Most Voted
Inline Feedbacks
View all comments
2 years ago

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?

Elijah John Yarra
Elijah John Yarra
2 years ago

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 »

1 year ago

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!

Simon Lidster
Simon Lidster
1 year ago

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?

1 year ago

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 ?

11 months ago

Hi Julian! Can I send video watched and percentage duration to Activecampaign? Please help me with that?

10 months ago

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:*** 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 »

10 months ago

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!

Last edited 10 months ago by Muiznieks
9 months ago

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?

Blog Categories

Join 30,000+ marketers getting exclusive resources and our latest content!

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.