×

ActiveCampaign Event Tracking with Google Tag Manager

Julian Juenemann

Last Modified on July 4, 2023

Wouldn’t it be great if you could send website event data to ActiveCampaign?

ActiveCampaign is a great tool for implementing your marketing campaigns. However, the process becomes a little complicated when we try to send the user information from Google Tag Manager to the ActiveCampaign account. 

GTM For Beginners

Sign up to the FREE GTM for Beginners Course...

In this guide, we’ll learn how to set up a tracking method that can send the user data from the Google Tag Manager to the user profiles in the ActiveCampaign account with the help of Google Cloud Functions.

If you’re new to Google Tag Manager, we’d suggest checking our Google Tag Manager tutorial first to go over the basics.

An overview of what we’ll cover: 

So let’s start!

An Overview of Event Tracking With GTM

ActiveCampaign makes a large number of digital marketing applications available for use. 

However, the process becomes complicated if you want to send the customer data from your Google Tag Manager account into the ActiveCampaign account. 

You’ll need to install a proxy here so that your ActiveCampaign and API keys don’t get exposed.

In a previous edition, we recommended configuring the Google App Script as an intermediate step between ActiveCampaign and Google Tag Manager. 

However, it is now an outdated method. Additionally, due to the hassle while setting up the same, we came up with this new method. 

You could also use Zapier. However, it isn’t built for tracking. So as you expand your data level on Zapier, it will become expensive in no time. 

We found that Google Cloud Functions, a product under the Google Cloud platform, can be helpful here. 

We can use this as a proxy and send data from Google Tag Manager to Google Cloud Functions, and finally send that data into ActiveCampaign to trigger the event tracking system. 

Google Cloud Functions is not only cost-effective, but it’s also reliable because it allows us to keep a log of the data. Hence we can see the process in real-time. 

To simplify the process, we have broken it down into four major steps. 

First, we’ll get an overview of the entire process. 

Next, we will be setting up the Cloud Function. This will act as our API proxy that enables us to send our data to the ActiveCampaign account. 

In the third part, we’ll set up a custom Tag template. We have specially developed this Tag for ActiveCampaign API that will enable us to send data from Google Tag Manager to the Cloud and finally to ActiveCampaign. 

In the fourth part, we’ll use specific techniques that will enable us to identify a user when they access our website and re-identify them when they take an action on our website. We’ll also learn to send this data to ActiveCampaign API. 

The fourth part is essential because it helps us to recognize users when they come to our website and what actions they perform. This helps us in making our system more effective. 

Let’s get started! 

How The Tracking Method Works

We want to send the event tracking information from our website to a specific ActiveCampaign contact. 

For example, if a user clicks on our website, our goal will be to send that information to ActiveCampaign. 

Checking information about the user to send it to ActiveCampaign with the help of Google Tag Manager

However, sending the event tracking information for different users is not as easy as creating a Tag on a page. 

This is because the event tracking information contains specifics that allow the information to be sent after a user has been identified. 

You need to send an Event Key along with the data to successfully track the users. 

Viewing Event Key for sending over tracking information to ActiveCampaign by proxy

Since this key needs to be confidential, we built this unique mechanism. 

We’ll first set up a Cloud Function on the Cloud platform. Then, we’ll send the data from Google Tag Manager to the Cloud Function. 

Finally, this Cloud Function will transfer our data to the ActiveCampaign. We’ll then need to find the correct user profile and forward the corresponding information. 

Towards the end, we’ll successfully be able to create the Google Tag Manager deployment. 

We’ll be using the Cloud Function Proxy URL and User Identification Method as Contact ID, Event Name, and Event Value

The correct information for input in Google Tag Manager deployment

We’ll also add a trigger to fire the Tag on a specific event on Google Tag Manager. 

Finally, the last part of the tracking deployment will be about user identification. 

Website User Identification

We need to identify the correct user when they come to our website and send the corresponding data to the right profile in ActiveCampaign. 

One of the easiest ways of executing this process is to attach a URL with a unique query string in an email that we send to the user. 

Sending the link attached with a string to the user by email

When the user clicks on that link and lands on our website, they will have a particular URL with a unique string attached. 

Attached string to a unique URL for tracking user movements

This will act as a contact record to uniquely identify the user to send further information. 

We need to retain this information because we may lose this string once the user jumps to any other URL on our website.

Detached string from URL when the user jumps to other URLs on the website

Hence, we’ll build a cookie to remember the string that was generated from the email. 

So at the end of this process, our Tag configuration should have all the essential information that we have spoken about.

Essential information for Tag configuration to send data to ActiveCampaign

We’ll also preview and test our Tag at the end. 

So open the website from the URL in the email with the string attached. 

In this case, the string number is three.

Let’s also go to any other sub URL to see whether we can track the user now. In this case, we performed an Add to Cart Click event. 

We’ll open our Google Tag Manager to check any Tags that were fired. 

Add to Cart Click event fired for ActiveCampaign event tracking in Google Tag Manager

Click on the Tag to open the details. We’ll see the correct user profile saved in a cookie beside the Active Campaign Contact ID. 

Correct user profile saved in a cookie beside Active Campaign Contact ID in fired Tag in Google Tag Manager

We can also relocate our user under a similar sequence number in the contact record. 

Relocating a user by the sequence number in the contact record

We can track all the Recent Activities made by the user when we click on it.

Reviewing recent activities performed by a user on your website

Additionally, there are a few things we need to take care of for this process to work. 

The Templates You Will Need

The first requirement is to set up a Cloud Function. This will act as our proxy where we’ll be sending our data. 

Next, we need to set up ActiveCampaign event tracking from Google Tag Manager. We’ve created a custom Tag template for that.

Finally, we need to find a process to identify a user with an email link, send that information to the right profile, and remember it through a cookie. 

Let’s start with the first step toward implementing this process!

Google Cloud setup

The first step is to set up the Active Campaign API and connect it to our Google Cloud Function. But to connect it to Google Cloud Function, we’ll need to first set up the account. 

We’ll need access to the Google Cloud Console for the Google Cloud Platform to set up Google Cloud Function.

We’ll go to the Google Cloud website. You can log in to it with your Gmail account, or you can sign up for a new account as well. 

As soon as you log in to your new account on Google Cloud, you’ll receive a credit of $300 for joining. 

However, you’ll still need to enter your credit card details to process this setup further. 

Adding a credit card to the process will enable us to send data to the system from an unauthenticated endpoint, which is an essential aspect of our process. 

Once you’ve signed in to an account on Google Cloud, click on Go to console

Opening console on the Google Cloud platform

This is where you’ll be able to find all your different projects with Google Cloud. But if you’re new to this, then click on New Project

Creating a new project on Google Cloud

Give a name to your project. Then click on Create

Creating a new project on Google Cloud

We now have a project under Google Cloud. 

Our next step will be to set up a billing process. 

On the home screen, click on Billing

Opening the billing section in Google Cloud

You’ll need to enter your account details here to successfully set up a billing process for Google Cloud. 

Furthermore, Cloud Functions are relatively cost-effective. For thousands of events that you may send per month, the charge will remain a few cents. 

But if you have a more comprehensive range of audiences on your website and you send millions of events, the charge can go up comparatively. 

However, we still find Google Cloud to be more cost-effective than other portals like Zapier. 

Once we have our account set up, we can start to build our Cloud Functions. 

How to Build Cloud Functions / Create Cloud Functions

Click on the Cloud Functions option on your home screen. You can also click on the pin icon to position it at the top of the home screen.

Pinning Cloud Functions on the Google cloud account menu

Once you’re on the Google Cloud Functions screen, click on CREATE FUNCTION to create a new function for our Active Campaign event. 

Creating a function on Google Cloud

Add a Function name so you can track it without hassle. You can also choose a Region for your campaign depending upon the type of requests you want to receive. 

Adding a function name and region to a new function on Google Cloud

Click on the option to Allow unauthenticated invocations. Also, click on the option to Require HTTPS

Click on Save once you’ve filled all the fields stated here. We’ll now go to Next

Filling up authentication information for a new Google Cloud Function

This will redirect you to a menu. Click on ENABLE API, which will enable the Cloud-built API. 

Enabling API on Google Cloud account

This will open a new window. Click on ENABLE

Enabling Cloud Build API on Google Cloud account

This might take a while to enable. Meanwhile, we’ll go back to our Google Cloud page. You’ll need the codes for the index.js file here. 

The codes are available in our repository

Open it and click on index.js

Accessing index.js codes from the repository

Now, click on Raw to open the codes. 

Opening raw index.js codes from the repository

Copy the entire code from here. Open our Google Cloud page again. Replace the existing codes with the ones we copied from the repository. 

At the very top of this code, you’ll need to fill up the information about the API key, API URL, Event Key, and Active Campaign account ID.

Information required for index.js codes on Google Cloud Functions

First, we’ll fill up the API key and URL. Open your Active Campaign Account for this information. On the homepage, click on Settings.

The opening settings on the ActiveCampaign account

Once the page loads, click on Developer. Here, you’ll find the API Access information. You can copy your API key and URL from here and paste them into the codes on index.js. 

Accessing API URL and key from Developer option in ActiveCampaign menu

As a rule, this information should not be shared with anyone. However, we have created a demo account for visual purposes only.

Once you add your information to the index.js code, you can be sure that your information won’t be shared publicly with anyone.

We just put this information to execute the Cloud Functions. Ensure that even after replacing your information on the codes, you have still retained the quotation marks.

Filling up information in indix.js codes in Google Cloud Functions

We’ll now learn how to fill up the ActiveCampaign ID and Event Key. 

ActiveCampaign ID and Event Key

Let’s go back to our Active Campaign account. Go to the Tracking option below the Developer.

We can see the Tracking Code here. We can find the Account ID in the code itself. Copy it from here and paste it into our index.js code. 

Accessing Account ID from Tracking information in ActiveCampaign account

Let’s come back to our ActiveCampaign account. You can find Event Tracking under the Tracking code. 

You’ll have to keep the Status as ON in case it isn’t. You can find your Event Key just below the ON option.

Accessing the event key by enabling event tracking on ActiveCampaign account

Copy the key from here and paste it to the index.js code on the Google Cloud account. 

Once all information has been added to the index.js code, click on package.json.

Opening package.json codes from Google Cloud Functions

You can find this code as well in our repository. Click on package.json

Accessing package.json codes from measureschool GitHub repository

You can directly copy the code from here and replace it with the code on your Google Cloud account. 

Copying package.json codes from measureschool GitHub repository

Now we’ll need to export the function while going to the endpoint. Hence, copy the function from the index.js code, and paste it as our Entry point.

Pasting indix.js function into the Entry point

Let’s deploy this function now.

Deploy Your Google Cloud Function

Once done, we’ll click on the DEPLOY option.

Deploying the Google Cloud Function

This may take a while to load. 

We’ll be able to see that our Cloud build API is now enabled. 

Enabled Google Cloud build API

Next, we’ll learn how to whitelist the events. 

Whitelisting Events in ActiveCampaign

We’ll now come back to the Tracking section in our ActiveCampaign account. 

We need to Add Event to whitelist it. We’ll type the name of the event we want to add for whitelisting beside it and click on Add

Adding events for whitelisting on ActiveCampaign account

Once added, you’ll be able to see the event listed under the Event section. 

Whitelisted events on ActiveCampaign account

Note: We can track only the white-listed events. 

ActiveCampaign will now be able to receive these events. 

Function Permissions

Let’s come back to our Google Cloud account.

As mentioned earlier, we need to Allow unauthenticated access to our Function. We’ll be able to check it once our Function has been deployed.

Checking unauthenticated access on the deployed event

You can also see them manually by clicking on PERMISSIONS on the top of the screen. 

Checking permissions for unauthenticated access for events

We can see that it will allow allUsers access in the description as well as Cloud Functions Invoker

Checking permissions for all users for ActiveCampaign tracking event

If you don’t already have allUsers access, you’ll need to set it up in order for this process to work.

We’ll now click on our event that has been deployed.

Opening ActiveCampaign tracking event for checking user actions on the Google Cloud account

It will lead us to the overview menu. It can show us how often an event was invoked.

You can check the Logs to see if there were any errors for any events that have been invoked.

Opening logs for checking user actions in the Google Cloud account

Let’s now see how to send this data to our ActiveCampaign account.

Sending First Test Data Into ActiveCampaign

We’ll first need our Cloud Function URL. So, we’ll click on EDIT

Editing function details to copy event tracking URL on Google Cloud account

Copy the trigger URL from here and paste it on your Notepad. 

Copying event tracking URL on Google Cloud account

Currently, this URL won’t work because we haven’t attached any information to it. 

However, we need to attach a testing string to the URL. You can find this string from our repository

Under Testing, you can find a string for Cloud Function URL. Copy this as well and paste it to your Notepad. 

Copying testing string from measureschool GitHub repository

Once you’ve copied the URL correctly, you also need to fill in your information. 

We’ll need to replace the EVENTNAME, EVENTDATA, and CONTACTID from the string given in the repository with dummy data to test it. 

Final URL for testing ActiveCampaign user movements

Let’s open Contacts on our ActiveCampaign account and create a dummy contact to test this data. Click on Add a contact

Adding a dummy user profile for testing event tracking on the Google Cloud account

Fill up the test data for a person, and click on Add

Creating a dummy user profile for testing event tracking on the ActiveCampaign account

Once you’ve added the information, you can also add Contact Actions. Choose any particular action and click on Apply.

Creating a dummy user event for testing event tracking on the ActiveCampaign account

You’ll now be able to see the test user data on your screen. Click on it to get more information. 

Opening the test user profile for checking the contact ID of the user

You can find the contact ID from the URL of the profile. In this case, it’s 2. 

Checking the test user profile for checking the contact id of the user

We’ll copy it and replace it with the CONTACTID in our testing URL.

Replacing the contact ID of the testing string URL with a dummy profile information

We’ll also need to fill up an event name. We have already whitelisted a few events in the Tracking column of our ActiveCampaign account. 

We can choose and copy the name of any one of these events. In this case, we’ve copied testing

Checking white listed events for adding into the testing URL to track user movements

We’ll replace EVENTNAME with the event we copied. 

Replacing the event name of the testing string URL with a dummy profile information

We’ll also replace EVENTDATA with any random property of an event. 

Replacing the event data of the testing string URL with a dummy profile information

We’ve chosen to add CloudFunction here. 

Once your entire URL is complete, you can copy and paste it on a new tab and press enter to load it. 

Final URL with the testing string to test the tracking of user movements

We’ll be able to see a message on the screen “sent event”.

Confirmation of successful testing string URL for tracking user movements

We’ll now be able to see this event on our Google Cloud console. 

It may not be visible right away. However, you’ll be able to see the user movements under the user profile that we created. 

We’ll be able to see the event name that we entered for the user, testing, in this case. 

The event can be seen as testing, and the event data can be seen as CloudFunctions, just like we entered. 

Tracking Recent Activities of users on the ActiveCampaign account

 Now our Cloud Function is ready to operate! 

Setting up Event Tracking Template

We’ll move on to the third part of our guide to set up a custom Tag template that you may install. 

First of all, we’ll open the GitHub repository. Click on ActiveCampaign Event Tracking.tpl, and open the Raw file.

Opening raw codes from measure school GitHub repository

Once the Raw file is open, click on Ctrl + S in order to save this file to your system in the tpl file format, and click on Save

Saving the event tracking codes as a tpl file

The file will now be saved to your system. 

Let’s open the Google Tag Manager account that is linked to your website. 

We’ll need to set up Tags and triggers for our process from scratch.

Open Templates on the home screen, and click on New

Creating a new template in the Google Tag Manager

Now go to three dots on the top of the screen, and click on Import.

Importing the event tracking codes to a new template on Google Tag Manager

Open the tpl file that we just saved. 

Once it opens, you can also check the code on the Template Editor. But ensure that you don’t make any changes to this file as it may not work otherwise. 

Checking the event tracking codes for a new template on Google Tag Manager

Save the file once it’s installed from your system into our template. 

We recommend you manually download them from GitHub as these codes can’t be found in the community gallery.

Cloud Functions may not be the standard way of performing this tracking, but we still recommend it due to its cost-effectiveness and ease of setup. 

Once ActiveCampaign is installed as a tech template, we’ll create a New Tag with ActiveCampaigning Event Tracking as its Tag type. 

Creating a Tag with ActiveCampaign Event Tracking type on Google Tag Manager

Now we need to add Tag information as well. The first one is Cloud Function Proxy URL. 

This will be the same URL as our Cloud Function URL. So, we’ll go to our Function on the Google Cloud account and click on EDIT

Editing function details to copy event tracking URL on the Google Cloud account

Copy the trigger URL from here and paste it into your Tag. 

Copying event tracking URL on Google Cloud account

Let’s see what else needs to be added to this Tag. 

Tag Configuration

We’ll need to put in the event information like User Identification Method, Event Name, and Event Value. 

First, we’ll choose the User Identification Method. Previously, we chose Contact ID as the method because we already had that information. 

However, you could also use other methods here. You can use the User Hash that you already have in the background. 

You can also use an Email Address, but we don’t recommend it due to PAI reasons. 

For ease of the process, we’ll again move forward with the Contact ID

Next, we’ll fill up the ActiveCampaign Contact ID. we already know this field, so we’ll fill up the Contact ID of our test user, which is 2 in this case. 

Next, for the Event Name, we’ll again go with testing

For the Event Value, we’ve just put in any value. We’ll put GTM in this case. 

We’ll also add a trigger for our Tag. We’ll choose All Pages as our trigger type. 

Let’s add a name to the Tag and Save it. 

Filling up Tag information for ActiveCampaign event tracking Tag on Google Tag Manager

Our next step will be to test the Tag we just created. 

So let’s see if it works! 

Initial Testing

Let’s preview our Tag on the website we have linked. 

We’ll be able to see that our event has been fired on the Google Tag Manager account. 

ActiveCampaign Tag fired on Google Tag Manager

Also, when we open the test user profile on the ActiveCampaign account, we’ll be able to see the corresponding event recorded. 

Checking recent activities of the test user on the ActiveCampaign account

So we’ve been successful in sending the event data from Google Tag Manager to the ActiveCampaign account. 

However, this is just for testing purposes. The trigger used here is All Pages. 

So if the user keeps on moving to the next pages continuously, there would be a tracking known as sidetracking that will go on. 

In order to prevent this, we need to customize our trigger. 

Add a Trigger

Let’s reopen the trigger from our Tag. Add a new trigger. 

Adding a new trigger on Google Tag Manager

Add a name to the trigger. Here, we’ll try to create a trigger for the click event of add to cart. 

We’ll choose the trigger type as Click – All Elements

We’ll set the trigger to fire on Some Clicks

Our conditions will be Click Text contains Add to cart

Once done, click on Save

Filling up trigger information for a click trigger on Google Tag Manager

Once the trigger is done, we’ll also make a few changes to the Tag. 

Setting up Variables

We’ll add the Event Name as a click

Make sure that the event names you choose are already whitelisted. 

We have previously whitelisted a few events. Make sure that you choose an event from them. Otherwise, it won’t appear on the ActiveCampaign account. 

List of whitelisted events on ActiveCampaign Account

For the Event Value, we’ll choose Page URL as the variable. 

Once done, click on Save

Filling up Tag information for ActiveCampaign event tracking Tag on Google Tag Manager

Let’s test it in Preview mode to see if it works! 

Final Testing

We’ll go to our website and add a product to the cart. When we come back to our Google Tag Manager account, we’ll be able to see that the event has fired successfully. 

ActiveCampaign Tag fired on Google Tag Manager

You can also see the same information on the test user profile from your ActiveCampaign account. 

Checking recent activities of the test user on the ActiveCampaign account

You can see the page URL shown in the event because that is how we have created it. 

Our next step will be to identify a user. 

We already know the Contact ID of the user that performs actions on our website. But now, we’ll find a way to dynamically identify this user as well to send this data to the correct ActiveCampaign profile. 

Adding a Dynamic User ID to Links

We’ll use a cookie technique to remember our users. 

We’ll need to set this process in the Google Tag manager itself. Here, we’ll change the way a user is identified in the Tag itself. 

Currently, we are manually providing the contact ID of the user inside the Tag itself. We’ll replace it with a dynamic system. 

So when a user comes to the website, we’ll identify the user and the corresponding profile on the ActiveCampaign account, and finally, we’ll send the data to the correct profile. 

There are several ways to do this process. The one which we recommend needs us to identify the users by links sent through emails. 

This is the most effective method in this case, as ActiveCampaign is also an email tool. 

We’ll send the email to the user with a link inside it. Once a user opens our website through the link provided, we’ll be able to track the user data with the help of the string attached to it. 

How can we send such information from ActiveCampaign? 

Emails from ActiveCampaign can be sent by campaigns, automation, or directly from the user profile. 

For testing purposes, we’ll choose to send an email from the user profile itself in the ActiveCampaign account. 

Click on Send an email

We can now send personalized information from the mail itself. For example, if we type “%”, it will direct us to convert it into a lot of other options. We’ve chosen the first name on the user profile. 

Sending a custom email from the ActiveCampaign account

We’ll also add a link to this email. Let’s type the website address in the link. 

However, we’ll need to add a query string at the end of this link. We’ll be including the account ID for this link. 

Hence, the string that we add after the website address will be /?acid=. We’ll also add the custom contact ID of the user to track them. 

So, we’ll also add %CONTACTID% at the end of the string after the “=” sign. 

We’ve chosen contact ID here because it’s the easiest method for our Tag configuration. However, you can also choose email if you are careful with it. In this case, the CONTACTID will change to EMAIL. 

Also, you can choose the subscriber hash option which is in sync with the Tag configuration. In this case, the CONTACTID will change to SUBSCRIBER_HASH.

We’ll go with the contact ID for convenience in the process. So, we’ll add the whole string “/?acid=%CONTACTID%” at the end of our website address, and click on OK

Adding a custom link with a query string to the email on the ActiveCampaign account

Send the test email once done. Let’s open the link from this mail to see how it works. 

Opening the link containing the query string from the email account for testing purposes

We can see that once the link opens, it suggests the exact ID number of the person as in our ActiveCampaign account. 

Checking the account ID number from the query string in the URL of the email

Let’s see how to add this contact ID information from the ActiveCampaign account to our Google Tag Manager account.

Pulling User ID From “URL” Into Google Tag Manager

First, we’ll need to create a new variable. 

Open Variables, and click on New

Creating a new variable on the Google Tag Manager account

The type of variable will be the URL variable, and our Component Type will be Query

We have chosen a Query key of “acid” for this purpose. 

Add a name to the variable, and Save it. 

Filling up details to create a URL variable on the Google Tag Manager account

After saving, we’ll see if this works. 

Let’s open the preview mode for our variable on the website. 

For testing the query, we’ll reopen the URL we mailed earlier for checking the contact ID of the test user. 

Once the website opens, we’ll come back to Google Tag Manager to see if it fired correctly. 

We can check in the Variable section the url – acid is showing a value of 3, and has been fired successfully. 

Checking the fired variables in the Google Tag Manager account

However, once we shift from the current page we opened on our website to any other page, we’ll be able to see that the string has disappeared from the URL. 

Let’s see how to track user movements in such cases.

Capture User ID in a Cookie With Google Tag Manager

In this case, our current Tag variable won’t be able to identify the user movements anymore. 

Furthermore, we can use cookies to remember the data in the Google Tag Manager. 

Cookies are a great way to track user movements irrespective of the number of times they change the URLs. We can always track them as long as they are on our website. 

Let’s create a cookie now. 

You can create a cookie in Google Tag Manager itself. Open a new Tag. 

We’ll choose the Tag type from the Community Template Gallery. 

Creating a custom Tag type from the community template gallery

We’ll search for the keyword “cookie”. We’ll be able to see many different solutions for creating cookies. Not all of them can actually make cookies. 

We have already tried out the Custom Cookie Tag for you, and it works properly. Click on it. 

Creating a custom cookie Tag in Google Tag Manager

Click on Add to workspace

Adding a custom cookie Tag to the workplace

Our Tag template is still open. Add a name to it. 

The Cookie Name can’t be changed to anything else. So we can just add any cookie number for it. 

We don’t need to fill in any Optional Description

Choose the Cookie Value as url – acid, the one which we have already created here. 

Save it once done. 

Creating a new Tag with a custom cookie type in the Google Tag Manager

We’ll also attach a trigger for this Tag. 

Choose the trigger type as Page View

We’ll command the trigger to fire on Some Page Values

We’ll keep the conditions as url – acid does not equal undefined

This is because we want to track the user when we already have a definite url acid and can put this value in the cookie. 

Add a name to the trigger, and Save it.

Filling up information for a page view trigger in the Google Tag Manager

Also, save the Tag. Let’s go to Preview mode and see how it’s working. 

Let’s again open the URL which contains the acid string along with the user ID, which is 3 in this case. 

Once the page has loaded, we’ll open the developer tools. Right-click on the website page, and click on Inspect Element

Opening developer tools by the inspect element option on the browser

Go to Application → Cookies. You’ll find a list of all the cookies here including the cookie that we just created, custom cookie 7. 

This will also show a value of 3, as our user ID is 3 in this case. 

Checking the cookies from the developer options in the browser

Even if you change the page you are currently on, the cookie will still be there. 

However, we still need to pull this information from the cookies into our Tag. 

Pulling User ID From “Cookie” Into Google Tag Manager

We’ll create another variable on Google Tag Manager. 

The variable type will be 1st Party Cookie, and Cookie Name can be copied from the developer options themselves. 

Copying the cookie name from the developer tools in the browser for the Tag in Google Tag Manager

The name is customCookie7 in this case. We’ll add a name to the variable and Save it. 

Adding information for a 1st party cookie variable in the Google Tag Manager

We’ll also implement it inside the Tag we created. We’ll change the ActiveCampaign Contact ID to customCookie7, and Save it. 

Adding cookie details as a substitute for contact ID on the Google Tag Manager account

Let’s preview this and see how it works. In order to preview correctly, we have deleted the previous cookie track to set new ones. 

Deleting the cookies from the browser with the help of developer tools

Let’s reload the URL with the string of user id. 

We’ll be able to see that our Tag has already fired on the Google Tag Manager. 

Checking the fired Tag on Google Tag Manager

We’ll also open another page on our website, so the URL doesn’t contain a string anymore. 

We’ll try to add a product to the cart. We’ll also be able to see that our Add to Cart Tag has also fired. 

The Tag also shows the ActiveCampaign Contact ID as 3. 

Checking the information of the fired Tag on Google Tag Manager

We’ll also see if this information is visible on the ActiveCampaign profile of the user. 

We’ll be able to see that the Click event has occurred on the user profile. 

Checking the recent user activity from the user profile in the ActiveCampaign account

You can even try to open other pages on your website with the same user ID, and you’ll still see that the Tags will fire.

As long as the user won’t change the browser or delete the cookies, we’ll still be able to track the movements on our website. 

However, you’ll need to make sure that any links you send to the users should have the query link attached to them. 

Unfortunately, there’s no other way to track this information by sidetracking on the ActiveCampaign. 

One thing we need to ensure here is that our process won’t track the users who come to the website without any query string attached to the URL. 

Creating a Blocking Trigger in Google Tag Manager

We need to build a negative trigger or a blocking trigger. 

We’ll create a new trigger with the trigger type as Custom Event

The Event Name will be all the events. Hence, we’ll type “.*”. 

We’ll click on the option to Use regex matching

We’ll set the trigger to fire on Some Custom Events

Our conditions will be cookie – customCookie7 equal undefined

We’ll add a name to the trigger and Save it. 

Filling up information for a custom trigger to counter the Tag trigger in Google Tag Manager

As the conditions in this trigger are counter to what we want, we’ll turn this trigger true as an exception for the one we already have. 

Let’s open our Tag and add this as an exception. Save the Tag once done.

Adding an exception trigger to a Tag in Google Tag Manager

We’ll again delete the existing cookies to test the new ones correctly. 

Let’s open our website without a query string URL and try adding a product to the cart. This is already a new string-free URL. 

We can see that the Tag didn’t fire. This is because our counter trigger stopped it from firing. 

Checking fired events in the Google Tag Manager

We have made a download of this entire container and added it as well to the GitHub repository

In case you don’t want to go through the whole setup, you can directly go to the Admin section, and click on Import Container

Importing the tracking container of codes from the Admin section in Google Tag Manager

You can add the container you downloaded from our repository here. 

Moreover, don’t forget that if you want to take this live, you’ll need to submit this as a version. 

FAQ

How do I implement event tracking using Google Tag Manager and Google Cloud Functions?

The implementation involves several steps:
1. Set up Google Cloud Functions to act as a proxy server for sending data to ActiveCampaign.
2. Configure event templates in Google Tag Manager to define the events you want to track.
3. Test and deploy the Cloud Function to handle event data and forward it to ActiveCampaign.
4. Set up triggers in Google Tag Manager to fire events based on specific user interactions.
5. Create variables in Google Tag Manager to capture data from URLs or cookies.
6. Verify the event tracking by testing it on your website

How do I set up user identification for event tracking in ActiveCampaign?

To identify users for event tracking, you can use links sent through emails. By including a unique identifier, such as the contact ID or email, in the query string of the URL, you can track users and associate their interactions with their corresponding profiles in ActiveCampaign.

What is event tracking in the context of ActiveCampaign and Google Tag Manager?

Event tracking refers to the process of capturing and sending specific user interactions or events on a website to ActiveCampaign for tracking and analysis. By using Google Tag Manager and Google Cloud Functions, you can set up a system to track and send event data to ActiveCampaign for targeted marketing campaigns.

Summary

So that’s all! This is how we can send the user data from Google Tag Manager into an ActiveCampaign account with the help of Google Cloud Functions. 

Sending user data to ActiveCampaign will require you to create a proxy in order to correctly identify the users. Furthermore, tracking this data will require cookies. 

However, if you have more user data on the ActiveCampaign account, instead you can pull the ActiveCampaign data into the Google Tag Manager to optimize it better.

Do you plan on using this event tracking with ActiveCampaign? What is your use case? You can let me know in the comments below!

Julian Juenemann

Julian is the web analytics instructor and the owner of MeasureSchool. He has 10+ years of experience in teaching analytics tools such as Google Analytics, Google Tag Manager and Looker Studio. He founded MeasureSchool to help marketers with the data-driven way of digital marketing.

Related Posts

Retargeting without Cookies blog featured image

Retargeting Without Cookies [Ultimate Guide]

Usman Qureshi

How to Build Google Analytics 4 Dashboards blog featured image

How to Build Google Analytics 4 Dashboards

Eric Huguenin

Subscribe
Notify of
guest
30 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Peter
Peter
5 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
5 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 »

Ana
Ana
4 years 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
4 years 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?

Sarah
Sarah
4 years 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 ?

Abdul
Abdul
3 years ago

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

Pau
Pau
3 years 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: 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 »

Muiznieks
Muiznieks
3 years 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 3 years ago by Muiznieks
Gabriele
Gabriele
3 years 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?

Kenneth
Kenneth
3 years ago

As far as I can test, this appoach does not work anymore, since you can not publish so annonymus can use the webapp?

It only excecutes for me, when I am on thje user that has the google app script..

Alex
Alex
3 years ago
Hello Julian, thanks to your youtube videos I managed to get some events to AC, but when I click on an option that changes my page, the event will be registered in the GTM, but it does not reach AC, whatever you think is the problem All the events that are carried out in a page are carried out without problems but when I change the page this does not work ???

Vincenzo
Vincenzo
2 years ago

Hi Julian, thanks a lot for the guide.

We have a Shopify Ecommerce, the script workks well, the only trouble is about email variable: ho can i fix it? I don’t find a data layer variable such as visitorEmail in Shopify; I have only the variable costumerId. May you halp me?

Talis
Talis
2 years ago

Hey, guys

Thanks for the stuff, show

But, I have a question:

How can I Add and edit a new contact using GTM by submitting to ActiveCampaign?

https://developers.activecampaign.com/reference/create-a-new-contact/

Last edited 2 years ago by Aleksa Filipovic
SasSvvy
SasSvvy
2 years ago

Thanks for this! I have created and started tracking page views. Can I also add in another tag to track all buttons or links clicked?

Markus Muhonen
Markus Muhonen
2 years ago

Hi Julian and the team,

Thanks a lot for this great guide. Implemented and it works perfectly!!! 🙂

However, I have another challenge to which the internet seems to have no answer. This is a bit off-topic, but I have already searched the whole internet and can’t find instructions.

Can we use API to send non-activecampaign custom HTML form data to activecampaign?

OR

Is there some other method to send non-activecampaign custom HTML form data to activecampaign?

I also went through activecampaign’s where several people have asked the same question, but not a single helpful answer.

Tim
Tim
2 years ago

Hi Julian,

We would like to add the product id to the tag at the cart page so we can send an abondoned cart mail with the correct product. Do you know how we add the product id or other information to the tag?

tim
tim
2 years ago

We have the dataLayer with the different product id’s. How would we send it to activecampaign? Would that be in the Event Value field?

Charles
Charles
10 months ago

Hi Julian, I’m encountering a really weird and specific bug and wanted to see if you had any info.

On every type of device these events are firing perfectly, EXCEPT for iphone/ iOS.

MacOS works fine, android works fine, but iOS doesn’t.

I debugged and found out that when using iOS, the 1st Party Cookie variable is always undefined, even though the url – acid variable grabs the string. So the cloud function doesn’t fire properly because contactid=undefined.

Would a potential solution be to try out a different vendor for the 1st party cookie tag? Or something else?

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.

Ready to take your digital marketing to the next level?

Subscribe to our newsletter and stay ahead with our latest tips and strategies.