- Event tracking like button click tracking,
phone tracking or link tracking is quite hard to set up.
Google Tag Manager makes our life easier
but unfortunately there's no direct connection
you can use to send event tracking data
to the email marketing automation tool Active Campaign
until now.
In this video, I'm gonna show you
how you can send dynamic event tracking data
to Active Campaign with the help of Google Tag Manager
and a Google Apps Script.
All and more coming up right after this.
(upbeat music)
Hi there and welcome to another video of measureschool.com
where we teach you the data-driven way of digital marketing.
My name is Julian and on this channel
we do tutorials, how-to videos
and take a look at the latest marketing tech
just like this one.
So if you haven't yet, consider subscribing.
Now we have been using the great email marketing
automation tool Active Campaign
on measureschool.com for quite some time now.
The capabilities of Active Campaign path
with the inexpensive price is quite amazing
and as you might know, we're always looking for ways
to make the data that we track with Google Tag Manager
more useful and more actionable.
We're looking for a way on how we can send
data to Active Campaign via Google Tag Manager.
Unfortunately, Active Campaign makes it hard to send
any data with Google Tag Manager into the tool
because there's no really native JavaScript API
available for it.
We came up with a workaround that utilizes
Google Apps Script to send dynamic event tracking data
into Active Campaign
and that's what I wanna show you today.
If you wanna download our script and the tag template
head over to measureschool.com/actracking.
And we got lots to cover so let's dive in.
Today our journey starts at this brand new
Active Campaign account
where we want to install event tracking.
How would this actually look like in the end?
Let's go over to Contacts.
And here we would see our contacts that we have
currently on our list.
Now we wanna send event data into one of these contacts.
For example here, we want on this profile
to show up on the All Activities our event tracking.
Now there is something called Site Tracking as well
which is pretty easily installed.
This will only give the URL that the user visited
and not interaction data that you can actually track
with the help of Google Tag Manager.
Before we can get started we need to do some configurations
so let's go over to our settings
and look on the tracking here.
And here we can install our site tracking.
Now, this is as I mentioned just a code that you can
plug into your Google Tag Manager account
to find all the pages,
some of them to our page view tag
that we file for Google Analytics
in order to do page view tracking.
But we want to actually go with the
more advanced event tracking option
which lets us send in custom data to our account
dynamically with the help of Google Tag Manager.
Activate this option and what we need right here
is our event key and later our account ID.
This is something that we need to copy in a second.
Now down here you need to actually
define your events in advance,
so you can't just send in any data into Active Campaign.
You need to define your events in advance
and there are always two fields available.
The actual name of the event
and then the event data.
For example, I could predefine events like clicked
or watched or added to cart,
and these would now all be available
to be sent into Active Campaign
with custom data attached to them.
How can we send data into Active Campaign?
Well, with the event tracking API.
Unfortunately, the recommended ways of doing this
is mainly through backend technology
so, server side communication between
your website server and the Active Campaign
event tracking API such as languages like PHP or Ruby.
Now Google Tag Manager is based completely on JavaScript
and we don't wanna expose any kind of API keys
with the request that we send
and that's why I came up with a solution
that actually utilizes a proxy via Google App Script.
Now, this is where the magic happens.
We will send the request into our Apps Script.
It will take the data, populate our API keys
and then send that data onto the Active Campaign
event tracking API.
To make a copy of this proxy,
you can head over to measureschool.com/aceventtracking
then you simply need to make a copy of this script
into your own Google Drive account.
And you're ready to use this Apps Script.
Now we need to fill out two parameters here,
one is the API key and then the Active Campaign ID.
How you can find them is described here
but as I mentioned already,
we have here our event key.
This is the key that we need
to put into our copy right here.
And then we need to have our account ID
which we have right here.
Copy that over and replace that.
That should do it.
Let's save this.
And the last step we need to go through
is actually publish it
so let's go to this publish button
and deploy as a web app.
And the only setting we need to change here
is that it is accessible to everybody
and we can deploy it as app.
Now, you will be granted to give this app permission
to actually send data out and receive data.
We'll connect to external services, allow this
and we get our web app URL.
Now with this URL, we can send our request.
So let's open up a new tab here
and I'm gonna enter our URL,
and this only works if you have
the right query string attached.
What is this query string?
I have a little example here.
It's basically the question mark
and then the key value path,
the key email, the key event and the key event data.
And after the equal sign you would put your values,
so you need to define the email
that this event should go to.
You need to define the event
which we have defined previously in our settings.
And the event data and this can be dynamic
that is attached to this event.
Let's present it here.
We get a response that this was successful
so we can go back to our account into the right contact
that we sent this to.
And we see now a new activity has been tracked.
A click event with the value that we sent over of test.
This works as expected.
Now, how can we make this useful in Google Tag Manager.
Well, we can use this URL,
let's copy that, to fire an event.
Now on my Google Tag Manager account,
I have come up with a little example
where I sent over an event for Outbound Link Clicks
to Google Analytics.
Let's go into our preview in debug mode here,
try these all out.
Here we have our website, our preview in debug mode opened
and if we click with the command key pressed
on an outbound link this will fire an event
which carries the values of event category
Outbound Link Click
and the event action is the URL
that was actually clicked.
How can we simulate this
with our Active Campaign tracking script?
Let's go back to Google Tag Manager
and the click track has already defined.
We actually showed you how to accomplish
the Outbound Link Click in another video
that you can check out as well if you wanna replicate this.
But now we want to build our AC tracking script
and what we would need to do all these
is actually three values.
Again, the event key that we have already defined
which is click, the click URL
and the email address that we want to attach this to.
Now, there are different methods of
actually getting the email address from the user.
One would be to actually get the email address
once it comes from a newsletter for example
that you sent out.
You could put that into the query string itself
and put it into a cookie so it's available to use later on.
We actually show you how to do this
in another video on pre-filling a form field
where this method is also used.
You could also capture the email address once
so it fills out the form
or the preferred way doing it with Google Tag Manager
would be to send that information into the data layer.
This would obviously also only happen
if the user is logged in.
On our example here we have a plug in running
that lets us, pre-fills our data layer for us
so in this first message here we have the visitor email
that is currently locked in.
I'm locked in on this online store right now
and therefore, this data is pushed to the data layer.
How will we get this out?
Well, let's build a data layer variable, go over here.
Simply click on New.
This is a data layer variable for our email.
Now we go ahead and choose our data layer variable.
We just need the key.
So what is the key exactly?
This is the first value here, visitor email.
Let's save this and we now have our email address
dynamically replaced on whoever is logged in.
Now we can go ahead and build our tag.
We will go over to our tag section here, click on New
and this will be our Active Campaign event tag
for outbound link clicks.
As a tag configuration we want to trigger this on
a URL that needs to get pinged
and we could also use custom HTML
but we just need to ping a URL,
the custom image tag will do.
Now, we enter here our URL for our web app,
let's go back here.
Here we go.
Let's copy that, put it in here
and our query string.
And obviously we need to replace
our email address dynamically
so I'm gonna delete this and click the variable button
to fill this dynamically with the data layer variable.
Let's see again here.
We send in the query string email equals.
It didn't put it on the right place.
Let's take this and stick it after the email key right here.
Then we want to have our event
which is predefined, this is click, we won't change that
but our event data is something we want to
dynamically change to the actual clicked URL
so we get the same results as in our Google Analytics event.
Again, we dynamically replace the email address
with our data layer value
and our event data with the click URL.
Leave the settings here untouched
and we'll go ahead and attach our
outbound link click trigger.
Again if you wanna know how to set this up
you can check out the video on outbound link click tracking.
Let's save all these and try it out, let's refresh.
Go back to our page, refresh here as well.
And I'm gonna click these links
with the command key press so they'll open up in a new tab.
And we see once I click them
an Active Campaign outbound link click got sent over
and this data should now be available
within our demo account.
Obviously the contact needs to be registered
within the system for this to happen
so let's go to our admin@demoshop
and we see all these information is now readily available
and it's dynamic because we can see
that the links actually changed dynamically
depending on what we have clicked on our page.
To spin this to the end you would need to
publish this as a version to all your users.
Then it would be live to use for all your users
and you would be tracking data
depending if the email address is actually available
once the user logs in.
Now, you can use that data very dynamically
to actually build automations in Active Campaign,
segment your data based on the different activities
and we actually use this at MeasureSchool
to build our abandon cart email campaigns
or when a user progresses through a course,
we would be able to send them emails
based on the progress that he has made within the course.
It's a really great feature to send in dynamic information
into Active Campaign without clogging up
all the different tags and custom fields
that you can define within Active Campaign.
So there you have it.
This is how you can send a dynamic event tracking data
into Active Campaign with the help of Google Tag Manager
and our Google Apps Script.
If you wanna download the script and the tag template
so you can upload it directly
into your Google Tag Manager account,
then head over to measureschool.com/actracking.
Now, I'd love to hear from you.
Do you plan on using this event tracking
with Active Campaign?
What are the use cases that you used this before?
Let me know in the comments below
and as always if you like this video
please share it with a friend or a colleague
and subscribe to this channel
because we'll bring you new videos every Wednesday.
My name is Julian, till next time.