by Dave | activecampaign
In this video, we’re gonna cover how you can update a custom field with the name of a tag. And this is important. For instance, if you have multiple lead magnets, you want to know which is the first one that got somebody onto your list. I’ll get more details as we go along. But here’s some things you need to keep in mind: begins with, hopefully, you have some kind of naming convention for your tags. Because for this script to work, we need to pick off something based on the first part of a tag.
And I’d recommend the first full word until the first whitespace. So as an example, I’ve got a couple tags one is called source-lead magnet A. So what we want to do is we want to set begins with to source, keep that in mind. And then second, we need a custom field where we’re going to place that. We need to get that code that’s linked below to your web server.
So let’s dive right in. To start with, we want to go to this URL, we want to copy all of this code right here, and we’re going to update this first section here, we’re gonna get our API URL and key, we’re going to have the tag that begins with so the first part of a tag, and then we’re gonna have a custom field that we need to type in there.
So let’s copy all this, you’ll need to be able to create a script on your website at PHP. So I’m in this web hook directory, I’m going to create a file called AC.php, it’s going to be a PHP extension, edit that paste in all of this code, go back to the top.
And now I need to go find this information. So where is that? So you want to go to your settings, your developer, click on API key and URL, it’ll be there. I’m not going to show that here. But I will update this in a minute. Now, which tags do I want to use. So I’m going to go into my account. And I’m going to use this person by the way.
So let’s go down and look at all the different tags I have. So I’m going to use for instance, Wistia, I’ve got 5 Wistia tags. So I’m going to use the word Wistia. that very first part is going to be the begins with only one to pick off tags that begin with Wistia. And I only want the first one.
So that goes right here. And then where do I want to store this information. Now I’m being super lazy, I’m just going to pick off one that I’ve already have. So I’m going to use this one called book sent, you probably want to use something for instance, like source, you just want to have a TextView. So there we go. Now I just need to update this. So this is updated with everything, we don’t want to do anything below line 13. And I’m going to go here to the web hook forward slash AC.php, and should just be a white screen, that’s all.
So now I want to copy this URL, let’s go back into Active Campaign, we’re going to create an automation, I’m going to just call it source, okay, doesn’t matter how you get somebody into here, I’m going to do start without a trigger, because I’m going to put them in manually, you could have all the tags that you’ve set up a trigger this that could be a little cumbersome, you might have hundreds of tags, my recommendation is actually put them in here from another automation. And the first thing you want to do is you want to check if that custom field and this one’s called books-sent. And okay, so this is the wrong one to use. Let’s not use that one because it’s a date based field. So let’s do something like a choose unique ability is my blank, click on Add. And the reason is, we’re going to populate that with something. So we want it to be blank until it we get the first River.
So I’m going to call this now if it’s empty, we want to populate it. So we’re going to send that person to this web hook. And that’s it. And this basically in the automation but I’m going to put a five minute wait in so we can just kind of see what’s going on.
Somehow they get put into here My recommendation is from another automation where they were tagged, we check is this field blank if it is send their information to this webhook URL, wait five minutes and then otherwise if they’ve already if this is already populated, go down this path. So let’s test this out. This unique ability is empty this person has 5 Wistia tags, and we should be populating the unique ability custom field with the first one.
So let’s put this person in there. So I’m going to add this person to here, click on OK. And momentarily I should have a new value the unique ability with one of those Wistia tags. So there it is. So this custom field was populated with the first occurrence of a tag that begins with the word Wistia. So that’s how you can update a custom field with the tag name.