View the session live or catch the replay here. You’ll find the recording and all related resources on this page once available.
Our live discussions are happening over in Slack. That’s where you can connect with speakers, join session threads, and chat with other attendees in real time.
Get ready to unleash the power of Marketing Cloud with AMPscript to deliver custom one-to-one personalization. In this session, learn five ways to use AMPscript to deliver the ideal customer experiences.
The methods we cover include options for customizing content, working with third-party links, pulling sales owner data, and making it easier for salespeople to follow up. Each example uses real data, so you can quickly and easily add these tips to your marketing efforts.
Speaker 0: How’s that screen share, Ryan? Is that looking okay?
Speaker 1: Yes. Perfect.
Speaker 0: Awesome. So I’m just gonna be in between that deck and then Yeah. In marketing cloud. So those are two places. And how’s that size as far as
Speaker 1: That’s a bit blurred.
Speaker 0: That’s a bit
Speaker 1: Yeah. That’s better. Some of it’s a bit blurred, uh, but people will know it, I think, because the marketing cloud users. Yeah. The Ampswitch is pretty hard to read.
Speaker 0: Is that too zoomed in, or is that
Speaker 1: Uh, Yeah. It’s it’s it was like hieroglyphics. Yeah. Might be my I’ve got very bad eyesight, but, uh, yeah.
Speaker 0: Yeah. You can’t
Speaker 1: really listen to Uh, hope you’re all well. We’re just gonna give it more than thirty more seconds, make sure we’ve got a full complement of people. So excited to have you all joining us. Uh, we have Tim Zaita here today from Cervelo in Boston, uh, and he’s got over five years experience of marketing cloud. I’m Ryan Hill from Sercante. I’ll be moderating today’s session. Before we get started, got a couple of housekeeping items to cover. So firstly, we’re gonna record the session. It will be available on demand after the event. We’ll also be following up with them via email. If you have any questions, post them in the chat. Uh, I will answer them or pass them to Tim to answer, and we can answer them in session. Please use the chat as much as you want. There’s lots of fun stuff in there, emojis, gifs. So let’s get started with Tim, and we will be discussing AMPscript and hyper personalization.
Speaker 0: Alright. Thank you, Ryan. Uh, thanks everybody for joining. And before I get started, I just wanted to say thank you to all of our incredible sponsors. Please take the time, uh, while you’re attending to stop by their areas to find out more about the amazing products that they, uh, provide. And like Ryan said, we’re gonna be talking about Amscript. We’re gonna be only going over those five tips and our use case, and then we’re gonna be right in the platform building out two different use cases to utilize and showcase those tips. And then at the end, we’ll do a quick recap and talk about resources. Okay. Ampscript. So as many of you you may have know, Ampscript is that proprietary coding language that’s used in Salesforce Marketing Cloud to bring out that great personalization in all of your email communications.
So when taking a look at those five next level tips, the first one that, you know, we always encourage is that to focus on those basics. Build that solid foundation in AMPscript so that you can add on complexity at the right pacing. So today we’re gonna be going over things like adding a custom code snippet AMPscript block to keep all of your AMPscript in that block, and then doing things like variableizing your data points. Uh, number two is leveraging those resources. We’re gonna be using the AMPscript guide a lot today. Uh, there’s also Stack Exchange and Trailblazer groups. You know, if you’re working through an Amscript, uh, issue, more often than not, there will be somebody out there in the community who’s worked through that before. So definitely lean on those amazing resources that are out there. Um, number three, own your code. So when you are if you do find that great code out there in the community and you do copy it into your environment, you know, break it down. Really understand it line by line so that you can really, uh, understand what it’s doing. So it’s not just like a mishmash of all these different copied, uh, codes. And do things like outputting, you know, the the data in your process so that you can see the code validated. Uh, number four is champion the big three. Lookups, if thens, and for loops. We’re gonna go through all of those today. Um, when you’re talking a bit more advanced Amscript, those are the big ones. There’s a ton of functions out there in Amscript, but those are the big ones that you’re gonna wanna focus on. And then push those limits. Once you’ve got that solid foundation, you can do anything with AMPscript, you know, only if it makes sense. Right? You don’t wanna incur too much tech debt. So in today’s session, we’re gonna be going over a dozen of those AMPscript functions, so it should be exciting.
Uh, so here’s our use case. So Northern Trail Outfitters has recently launched a loyalty program, and they wanna begin communicating to their members. They all they wanna develop a personalized and engaging email stream. So our first build is just going through basic practices of personalization, and then our second build is gonna be, you know, building off of that using some more custom personalization to output custom loyalty steps for each of those loyalty members. In our, um, best practices personalization use case, we’re gonna be doing things like looking at what, uh, you know, personalization strings versus setting an AMP script variable, setting up that code snippet block, some best practices, and formatting.
Here’s a quick overview of those functions that we’re gonna be using. Attribute values, the first one we’re using, that normalizes your data when you when you verbalize it, so so that makes it easier for all of the functions you’re gonna use after that. The v function is a very basic function, just outputs those variables in your code. Empty, we’ll be using an if statement, returns a true value if it’s not empty, and then some formatting like proper case, the initial cap, using substring and subtract to help pull out parse different parts of your text or your data points, and then even using a tool like index of, uh, which we’ll be going through today as well.
Alright. So let’s jump right into the platform. We’re gonna go into marketing cloud, and then first off, I just wanna make sure that I’ve got this sized correctly so people can see, um, from a tech standpoint. Let me just increase this a little bit to see if that helps. Ryan, how’s that looking? Are people can people see this? Uh, is that clear as far as, uh, what we’re I’m showing here because we’re doing a little bit of coding today.
Speaker 1: If I yeah. You can zoom in on the Goldcast guys by, uh, just touching your touchpad and zooming in. It comes you can get into that little bit there, and I’ve done that, and it looks better. So if you need to, please zoom in and let us know if you can’t see it, please.
Speaker 0: Thank you. Okay. So we’ve got a basic email here set up. So this is our welcome email that we’re gonna be sending, um, to our loyalty members. And we’ve got some basic personalization here, this percent percent name variable. So to understand what this is doing, um, we’ve got another tab open in marketing cloud and what we’ve got here are a list of data extensions we’re going to be using today. So this first date extension, this is our, uh, data extension that we’re going to be using to send our email. So it has a list of those emails that would be sent for that loyalty program. And this is where that name field is being pulled in that we’re gonna be doing with this basic AMPscript using that value of just percent percent, the value within the date extension. So when we hit preview on this, we should see that, um, field get populated. So here’s that name field in the data extension, and see we’re seeing Kristen here, uh, populated. So there it is your basic AMPscript using that percent percent syntax.
So we’re gonna wanna take this to a next level and start variableizing your code, um, and building that within an AMPscript, uh, code snippet block. So the first thing we’re gonna do is we’re gonna navigate up to the top of this email and we’re gonna go back into content builder. And what we’re gonna wanna do is just create a code snippet block near the top of our email where we can, uh, capture all of our AMPscript. To do that, we’re gonna open up our AMPscript block by using a percent percent open bracket. We’re gonna create a little bit of space in here and we’re gonna close that bracket and percent percent. Now we can do all of our AMPscript coding within this block. So the first thing that we’re gonna wanna do is we wanna create a variable for that greeting. Instead of using that percent percent name value of the date extension, we wanna create a variable. So since that looked like it was a first name, let’s call this variable first name. And what we’re gonna want to do is we want to create a variable to use that. We’re gonna want to use the attribute value function and we want to copy that field that we want to pull in that name field. And I typically like to do is literally go right to the date extension and copy that field. We could just type in name, but sometimes that does help when your values get a little bit complicated. You’ll know you’re bringing over the right syntax. Um, I also created this var statement up above which is kind of best practices to declare your variables, and that’s what that var statement does. Okay, so here’s a very basic implementation of our first step, which is to create take that variable of that name and variableize it into that first name value. Again, that’s attribute value is gonna normalize your data so it’s consistent when we’re gonna use it down the road.
So to output this variable, we’re gonna use our second, uh, amp script, um, function, which is the v functions. We’re just gonna modify this right here. We’re gonna do an equal sign. We’re gonna do the v function, and then we’re gonna put in our variable, which was first name. And let’s just close out that paren and the equals. So there we go. Now we’ve taken that variable that we’ve created in our code snippet, and now we should be able to when we preview this again, it should output, uh, Kristen just like we had her there before. Okay. So we’re starting to build those those building blocks, uh, to output those names.
Okay. So now let’s let’s take a look at our data extension and sort of scroll through to see if this is working for all records. So we’re gonna just go through this data extension. When you have a data extension hooked up, there are seven different records in here. All you do is go up into this subscriber preview, and you can sort of cycle through all of these different records. So as we’re seeing in this data, we see, you know, Kristen does appear here. But for this next record, there’s no name populated in here. So we’re seeing, like, something missing in our dataset. Um, so this is not the best, uh, outcome for somebody. We wanna, you know, populate their first name. And so how do we do that? How do we solve that that problem where when that name field isn’t populated, is there another way we can populate a first name in there? So luckily, we have a another date extension, which is this universal file date extension. So you’ll see this commonly with those marketing cloud environments that are not typically tiled, uh, tagged to, uh, or tied to Salesforce CRM, where you’ll find that there will be a data extension, a universal data extension that will have all of the subscribers and then a wide variety of data points that are available for that subscriber. So in this case, this universal data extension, you can see there’s some gaps in some of the data for the first name, but there’s also this full name field, which has all of the data available. So what we wanna do in our solution is we wanna check to see if that first name variable which we just set, if it’s empty, we wanna go up and look into this data extension under this full name column and pull in that name as our backup.
So to do that, we wanna use one of our more advanced functions, a lookup function, and and make that happen in our AMPscript. So what we’re gonna do is go into the AMPscript guide. Uh, there’s a link in the in the end of this doc. I’m sure everyone might be familiar with this. This is a fantastic guide. It’s a free service where you can just find out all of the functions within amp script. You can subscribe. Definitely recommend subscribing and getting the amp script guidebook. So let’s look for the lookup function. And, uh, so amp script guide is incredibly helpful in what they provide. They do it in these two sections. The first section gives you an overview of the function, you know, what it does, and it breaks down all of the different fields in the function. And then it also gives you just a fantastic real life example down here at the bottom.
So let’s take a look at what lookup is going excuse me. Look lookup is going to do. It’s got four fields that we need to provide. The first field is the name of the data extension that we wanna pull this data from. The second field is the column or the field that we wanna return as the variable. So in this example, it would be that full name from the date extension. The third, uh, value is the column in the date extension that is going to correspond to the subscriber or the data that you were actually searching for. And then the fourth field is the actual value that’s gonna be searching for in that column. So we’re gonna go down into this example, and we’re just gonna literally copy this code because it’s pretty excellent. And we’re gonna bring this back into our email, and we’re gonna go back to the content tab, and we’re gonna go into our block. And let’s just paste this in here, and we can start filling this out. So I’m just gonna correct this, so this isn’t all caps. Let’s change this to this is gonna be supposed to call this full name, is what we’re returning. Alright.
So let’s start filling out this function. First field was the date extension that we’re looking to look up. So here’s that date extension. Here’s that name. So we’re just gonna copy that, and we’re gonna paste that in here. Hold on one second. I think I copied the wrong thing. Let me just copy that, and let’s paste that into here. Okay. Excellent. The second field is the value that we wanna return from this date extension, the column. And for that example, it’s gonna be full name. So, again, I’m gonna go over to this tab, and we’re gonna scroll down to this full name variable. And let’s just copy that, and then we’re gonna paste that into our second, uh, second area there. Okay. The next field is the field in this data extension that identifies the record that we’re doing, uh, doing our lookup. So in this example, the universal file is all based on this subscriber key field. So every subscriber has its own unique subscriber key. It’s like that golden record identifier in marketing cloud. And what we just need to do is confirm in our email send date extension that that subscriber key is the same. So, yeah, we’ve got the subscriber key, and that is what is we’re gonna be using to link into this universal file. So the field that we’re looking to make that link is subscriber key in the date extension that we’re doing the lookup. So we’re gonna pass that into here. It’s already there, but we’ll just paste that over anyways. And then the last field is the actual subscriber key itself. Now this is gonna come from that email send date extension. So because every, uh, email send file or field, uh, row is gonna have its own subscriber key and there’s that field there subscriber key that we’re gonna bring through. So again, we’re gonna want to for every single one of these email sent, we’re gonna wanna use this subscriber key to determine that lookup. So what we need to do here in this example, let’s just paste in that syntax for subscriber key. Now we need to establish another variable for subscriber key. So let’s just copy this syntax. I paste it in here. Let’s call this variable subscriber key, and then we’re just going to take that syntax and paste in that attribute value again using the attribute value to normalize the data, and then our lookup value is going to be that subscriber key. Okay. Excellent.
So now that we have this, uh, variable, uh, created, we’re gonna do a a tip, um, which we had in our, uh, five tips, which was to help to output this code so we can validate that we’re actually seeing that come through. So we’re gonna do is we’re gonna copy this variable, and this is just for testing purposes, but just so that we can see that we’re gonna duplicate this block. We’re gonna go in here and we’re gonna go in the HTML. And let’s just say this is going to be we wanna output the full name for each one of these records just to validate the data. Alright. And then we’re gonna be outputting a full name And the double okay. That looks good. Alright. So let’s preview and test that and just see that we we should be for every one of these records, we should see that full name being outputted. Okay. So we’re not seeing that that outputted here, and I think that’s because I didn’t set my variable, uh, correctly. So let’s go back into our code snippet And, um, oh, sorry. Let me just delete that. Let’s go in here. Okay. So the full name is what we want to output. So we should be able to see that when we preview that. That’s the v. So let’s just preview that one more time and see what we’ve got here. Okay. So here’s that example where we’ve got that name field isn’t present, but we’re seeing it’s pulling in Patty Carlson based on that subscriber key. If we try Kristen, so we’re seeing Kristen Medina, that’s that full name. So it’s great. We’re seeing that that lookup is now working, and we’ve got that outputted.
So now what we wanna do is we wanna have it outputted here only when that name field is blank. So let’s go back into our code snippet, and here’s where we’re gonna wanna use our if then statement. So we’re gonna do an if, um, empty, another function. If this first name variable is empty, then we wanna set now what we’re gonna wanna do is we wanna create a new variable called greeting, which we can use for both of these, um, both of these options. So if that first name is empty, then we’re gonna wanna set our greeting to that lookup value. And then else, if it’s if it is if it isn’t empty, then let’s set the at greeting variable to the first name. And then we’re gonna do an end if. Okay. So quick overview of if statements. If statements have three key variables, the if itself, the then, which is gonna be, you know, if it’s if this is true, then what does it do? And then the last part is this end if. You always have to end with an end if. In our example, we’re using an else here, uh, as well, but those are the three, the if, then, and end if. And then we like to indent in our if statements just so you can see what is covered in that if.
Okay. So now let’s now that we’ve got that logic in place, let’s go back into our email, and then let’s just change this variable to greeting. And hopefully, we should see this now working where it should be, uh, showing at least some sort of greeting, um, for all of the different scenarios that are in these data extensions. So here we go. Uh, Patty Carlson is now, uh, outputting correctly as that dear name. And, uh, if we go to Kristen, her first name is still being populated. So now we’ve got this data looking really good. We’re getting some consistency within our data, and it’s working for all scenarios. But as you can see as I’m scrolling through this, we’ve got some continued inconsistencies with this data. Ideally, we’d like to just always output the first name and not the last name, and then we’re also seeing that the data is in a variety of different formatings. This is all caps. Previous one was lowercase.
So let’s tackle the first part. First part is we wanna if if it is a full name, we wanna truncate it so it just outputs the first name. So so how do we do that? So let’s go back into our AMPscript in our content block, and we’re gonna search for in our AMPscript guide, we’re gonna search for this cool little function called substring. Now substring will return a portion of a specified string of text. It’s pretty straightforward. The first value is the string or the variable which you’re looking to extract the portion. The second variable is the starting position. For us, it’s gonna be like the first position because we want the first name. And the last part is the tricky part. This is the length of the actual, uh, substring that you’re looking at, the actual value you’re looking to return. So we don’t know. Chris could be five letters. Uh, Meg could be three letters. So that’s the one that’s gonna be kinda custom. If we scroll down to the AMPscript guide, they’ve got a bunch of different examples here, and this is our exact example. So in him in this example, we’ve got a full name, which is Kurt Harris, and this substring code will actually return just the first name. So here it is. Here’s that that code right here, but we’re not gonna steal this code. We’re not gonna copy this code. We’re gonna build this from scratch so we can really understand it. This goes back to my, you know, my third, uh, tip, which is really understand your code.
So we’re gonna take substring. I’m gonna see if we can do this on our own. So we’re gonna go back into here into our code snippet. Let’s paste in this substring value. Okay. So the first value for substring is gonna be the greeting itself. That’s the full name that we wanna, uh, extract and pull out just the first name. So easy. One third of it’s done. The second value is the starting position. It’s gonna be first name, so it’s position number one. Fantastic. The last, um, part is the tricky part. How do we know the length of that first name? So that’s the part that we need to work through, and this is where we’re gonna need to add another function to do that. So luckily, there’s a function in Amscript called index of. So let’s just search for that index of. Pull this up. What index of does, it returns the position or the number of characters where there’s a first occurrence of what you’re looking for. So the it’s pretty straightforward. What you’re gonna be doing in index of, we’re gonna be looking at the string or the variable, and you’re gonna it’s gonna return this value, uh, this point within that string or in that text, the character of when that exists. So in our example, let’s copy this code. What we know when the first name ends is there’s a space between first name and last name. So we’re gonna copy this index of, uh, syntax. We’re gonna take this greeting, and that is gonna be our first variable. And then we wanna return where a there is a space. We’re just gonna literally add a space in there, um, and that’s gonna be the the the the variable. So what we wanna do is we’re gonna wanna set add greeting equal to this substring code. Let’s just output that now and take a look at what we get. So what we’re gonna wanna do is do this right after we set it in the if statement itself. So let’s go in and preview this and see how close we get. Can did it did it output just the first name? So we’re gonna preview this. And there we go. Look. Chris was Chris Nori, and then it got reduced to just Chris. We’re getting there. It’s looking really good. Um, except we got a space in here now. And that’s the one thing that’s it’s super close, but we’ve got this extra space that we wanna get rid of.
So how do we do that? Just wanna get rid of that extra space. So there’s a way to do that. So we basically wanna say so, like, we want this string, this, um, this first name to end not at the space, but we wanna end it at one space before it, which is the last character of the first name. So let’s go into our AMPscript log, and we’re gonna look for this cool function called subtract. And let’s go into subtract. Subtract is very straightforward. Um, basically, what you’re doing is you’re taking the first value, and you’re subtracting the second value from it. So let’s copy the syntax. Let’s go into our amp script block. Now we wanna place this correctly. So we’re gonna be subtracting this variable here. The first variable is this index of greeting, uh, variable itself. So that’s the first part of that variable. The second part is that we wanna subtract just one, um, one, um, character, and we wanna add a parent in there. Let’s see if I did that correctly. Let’s preview that. There it is. Patty is now reduced. Let’s go check Chris. I think he’s further down in the state extension. Yeah. There we go. That space has been reduced.
So let’s just quick do a quick summary of what we just did there. So it’s like a three function, um, you know, nested function. We’re taking the index of that greeting to find where that blank space is. We’re subtracting one character to go back to the end of that, and then we’re using substring to use that same logic. So So there’s a good example of how you could have just literally copied and dropped this into your AMPscript code, but really breaking it down and understanding each one of those, you get to to understand three different functions. And then if you ever had a problem or a different use case, you’d be able to know, uh, what you’re doing there.
Okay. So that’s that’s that that second part where we’ve been able to reduce down to the first name. The last part is we want, um, an ability to normalize our data from a formatting standpoint. Let’s try to get them all initial capped. So when we go into the AMPscript guide, there is a proper case, um, function which will return the, uh, init will initial cap your variable. So let’s just copy this proper case syntax. We’re gonna go back into our AMPscript. And here we’re gonna go in line to our greeting here. We’re gonna go into our HTML editor, and we’re just gonna copy in that proper case. So let’s, um, do that, and let’s preview, and hopefully that will work. There we go. Chris is now initial caps. Amanda is no longer all caps. So there we go. We’ve got our solution. Everything’s looking really good from this standpoint.
Okay. So this whole exercise was all around a single data point, personalizing the first name. But as you can see, we built some complex functionality within AMPscript and built it up slowly. And the great thing about this, uh, code snippet block is that all of your AMPscript is located in one place. It’s all organized. It’s in order. It’s not in several different blocks. It’s another benefit of using those, um, a code snippet block. So one thing I wanna do here is I want to, um, I kinda don’t like seeing this Amps script block in my email, so there’s a little trick you can do to clean that up. So I’m just gonna do about side of the Amps script block. If you use this syntax, it just sort of removes it from the view. It’s kinda nice. Alright. There we go.
Alright. So that’s our first use case done. Our second use case, if we go back to our deck real quick here, is that we want to, um, do it add some little bit more advanced functionality to our welcome email. So with every loyalty member, um, you can take advantage of your loyalty program, um, with all these different steps. So when you join, there might be a step to refer a friend or to make a purchase, whatever. Uh, so every loyalty member has different steps. They could have two steps. They could have three steps. They’re all different. And so what we wanna do is we wanna have this email output all of those custom steps on a subscriber by subscriber basis. So we’re gonna look use advanced lookup rows function, uh, for that. We’re gonna use the concat function to output that entire section of customized. And then if we can get have time to do it, we’re gonna go into the if then inline, uh, function as well. So we’re gonna be looking doing, um, lookup rows. If we have time, we’ll look do the lookup ordered rows, um, going through that function. And then we’re also gonna be breaking down for loops, which is gonna be in the lookup rows functionality, all the different specific, uh, characteristics of a for loop, and then wrap it up with, uh, concat our concat function as well.
So let’s go back into our email. And thank you. Yes. I’d like to continue working. So what I wanna do is I wanna add to this, uh, block. I just wanna add a quick sentence in here that talks about these loyalty steps. So I’m just gonna add a b r here. Let’s add one more. And let’s say, to take advantage of your loyalty program. Please follow these steps. Colon, and let’s just do a b r. Fantastic. Okay. So now below this is where we’re gonna wanna render this custom content of all of those steps that correspond to each subscriber.
Okay. Now to find those steps, we’ve got another data extension that has been created by our, uh, IT team, and it’s a database of all of these steps. So there’s a it’s a laundry list of all the steps. They’re not able to attribute those to each row of subscribers in that universal file because there are multiple, uh, steps. So they’ve got this database of all of the steps, and they correspond to each subscriber. So there’s a variety of different subscribers in here. There might be a subscriber, might have two rows in here. One other one might have five. They’re all identified by that subscriber key. And then we’ve got a couple of different fields we wanna output. We wanna output the step itself, and then we wanna output this bonus month that if they accomplish this step by this month, they’ll get extra bonus points. So what we wanna do is we wanna do a lookup to this date extension based on that subscriber key that we’re emailing, and we wanna output not only two different fields, but we also wanna pull in every single row that’s associated with that subscriber key. So that’s where we’re gonna wanna do a slight variation on lookups to look up rows. Lookups is fantastic if you’re looking to return a single value on a single row, But if you have multiple values and multiple rows, lookup rows is your, uh, tool there.
It’s a little bit simpler syntax wise. It’s very similar to lookup where the first field is the name of the date extension, and the third and the fourth field of lookup is the same for lookup rows. It’s the name of the column that identifies the row, and it’s identifying that that third is the the value that’s identifying that specific subscriber. So if we scroll down here, AMPscript Guide has a fantastic use case, uh, example that we’re gonna copy. So we’re gonna go down and just copy this entire, um, example all the way down to here. We’re gonna bring that into our code snippet. So we’re gonna scroll back up into our code snippet, and let’s create a little bit of space here. We’re gonna paste that in. Okay. Perfect.
So let’s start off with our first, uh, the function, the lookup rows. So the first field we want to populate is the name of the date extension. So we’re gonna go into that date extension. We’re gonna copy this welcome steps name. We’re gonna paste that in here. The next field that we want to, um, identify is the field in this date extension which identifies which in our case is that subscriber key. So in this one, it’s the actual customer. We can see that subscriber syntax that we’re familiar with. So we’re gonna copy this customer uh, column, and that is gonna be our second field. And then this the field that we’re looking up is the subscriber key. So luckily, we’ve already set that value, this variable up here. So let’s just copy this down here, and we’re gonna paste it in here. Alright. So we’ve got the lookup rows function filled out. That’s the easy part.
Now we’re gonna go into the for loop that accompanies this lookup rows, uh, function. So, um, I’m gonna do a little bit of cleanup here. This is not needed for our code. And then I’m gonna also clean up a little bit down here. This is not needed for this use case as well. This is all was an inline example, but it’s not what we’re looking for. We’re gonna take a little bit, and we’re gonna go through what we’ve I’m I’ve got here just in a second. Let me just clean this up and move this up a little bit. Okay. Okay. So the the value that lookup rows gets set to is this at rows. Now what gets returned from a lookup’s, uh, function is this value that doesn’t really have, uh, something that you can use within our function. So this is where we’re gonna use our first value, our first function within AMPscript, which is row count. What row count does is that it takes this value that gets returned from your lookups call, and it converts it into a number that is helpful, like a number of four. It says I there are four records in here that I want to cycle through in my for loop. So that’s what row count does. Next up is our if statement. We’re very familiar with that. So we want to say if that count is greater than zero, if there are more than one, uh, more than zero, uh, rows found in the state extension, then go through and do the for loop. Alright. Now we’re gonna get into the for loop itself. Now the for loop, it starts with a for for loop and it ends with a next. So in that for loop, you’re gonna wanna create this variable, this at I variable, which is gonna be your counter. And so we want this variable to go through one, start at the number of one, the first row, and you want it to go through every single that row, uh, all the way through the row count to do that. And what you’re gonna be doing are these variables here that are gonna be in your for loop. So I’m gonna delete these variables for right now. The next variable that we are gonna be using is this row variable. So what this row variable does, it sets and identifies the specific row that you are in in your rope in in your for loop. So if it’s you’re in you’re in, uh, the for loop, uh, count number two, that’s the row it’s gonna determine to pull in. And then the last, uh, value in a for loop is the field. So this field is going to return based on that row, the field that’s associated with the column in that date extension. So to fill that out, let’s get our first view field that we wanna return is step. So in the date extension, there’s that step field that we wanna bring in. So we’re gonna copy that syntax. We’re gonna paste that in here. And then the next, uh, field that we wanna bring in is this bonus month. And then we’re gonna go back to our date extension in here, and we’re gonna copy in bonus month, and we’re gonna paste that in there as well. Okay. That’s that’s it for as far as the for loop. What we’ll wanna also do is to is, um, declare both of these variables in our for loop so that each time it goes through the loop, those values get nulled out before they get set again. Okay. So basically what this is gonna do is gonna say if I find three, uh, rows associated with the subscriber, I’m gonna go through this exercise and set these variables three times. So the last part that we what we need to do is we need to create a variable that is going to collect all of those fields each time it goes through, um, that that, uh, that for loop. So what we’re gonna wanna do is let’s let’s call this our loyalty output variable. Now we’re gonna use this concat function, which is basically just gonna concatenate these steps and these bonus months each time it goes through the for loop. So whenever you’re doing this, you wanna start out your concat with the variable itself because it wants to build on itself. And then within the concat, you can add a combination of text, HTML, and variables to fill out each one of those rows that you’re gonna create. So in our example, let’s say we wanna put in loyalty step. Let’s make that a colon and a space. And then we wanna output the step itself after that text. And then let’s put in another variable, which we’ll just use a comma, and let’s say bonus month, colon, space. And then we’re gonna put in our bonus month variable to output that right after that little piece of text. And then last but not least, because we wanna have each one of these output as single rows, um, in the output, we’re gonna also wanna include some HTML pay return as well. Okay. So each time it’s going to create a new row of data that we can output, um, in that for loop. The last part that we didn’t cover was this end if. That is the end if that wraps up this if statement here. Okay. So now with this set, let’s go back into our, uh, content block, and we’re gonna simply just output this variable and hopefully, fingers crossed, it’s going to output all of that data that comes from all of those for loops. So all we’re gonna do is a percent percent equals the we’re gonna paste in that variable, and we’re gonna do an equals percent percent as well. So let’s just preview that real quick and see if that works.
Speaker 1: Tim, quick time check. Uh, we’ve got four minutes to go.
Speaker 0: Thank you, Ryan. Appreciate that. We are getting very close. So here we go. Here’s that output. It for, uh, Kristen, Kristen has three different, uh, loyalty steps, refer a friend, sign up for a loyalty program, refer a friend as well. The three different types, uh, of of of, uh, of months as well. If we take a look at, um, Chris, Chris has only two different, uh, two well, two different loyalty steps. We probably need a, uh, something of that bold return there to return that. But now we’re seeing how these variables can be output and customized based on that lookup there. Uh, let me just quickly go in here. And, um, one other thing I wanted to output is I wanted to output this row count as well so that we can see the row count and validate that each row count has its own, uh, number. So let’s preview that again, and this should hopefully output the row counts so that you can validate that it’s cycling through. So example, Chris has two rows, and you can see he’s got two rows of data. This one’s not he’s come coming through. You know, uh, Kristen has four as well. So anyways, sorry. I’m gonna wrap up pretty quickly. Here’s an example of how you can use the CONCAT statement to output all this custom variables and create any sort of content that you want in, uh, in the AMPscript itself. And that’s using that lookup rows and also for loops. So let me just hop right back into our slides. We’ll do a quick wrap up because we’re running out of time. And, okay. So those are those tips. Hopefully that was helpful. I wanted to quickly, uh, cover some of these resources. Again, we can you can find, uh, we can share this deck. There are a lot of resources, a lot of which we covered today, the AMPscript guide. There’s the Phoenix SFMC, uh, group. Definitely highly recommend. They have a lot of hands on, uh, sessions where you can learn AMPscript. They have an AMPscript boot camp. There’s some great videos there. And there’s also this great tool called AMPscript 30, uh, where you can do thirty days worth of AMPscript, um, building, uh, and exploring those different functions. So that’s it. Just wanted to wrap that up and say thank you and open up for any questions. Anybody have any questions on what we covered today? Alright. Well, just because I’m a little nerdy, I want to figure out why that is not returning. So I wanna go into this. I think I just need an extra return bold return there, and I think that would come out a little bit nicer. And then the only thing else I wanna do is I wanna add a bold to this text just so that comes out a little bit nicer as well. So I’m a add a bold tag there, and then I’m gonna add another bold tag at the end that did not have that be bold. Let’s see if that hopefully should have a little bit better of a preview of that content. There we go. So there’s it’s coming out. It’s got the loyalty step, uh, bolded. There’s that full list. It was sort of, uh, needed a bold return, uh, or a break return, uh, there. So any questions? I know we only got a minute left. Any questions on in on the AMP script that we’ve learned today?
Speaker 1: Does lookup pros allow you to filter records from the data extension, or do you have to use a loop for that?
Speaker 0: Great question. Yes. So you can filter in lookup, uh, rows. So if, um, you what you could do is say your, uh, bonus month, you wouldn’t wanna do any bonus months for December. You could do an if statement after that is set and say, if bonus month equals December, then do
Speaker 1: Top marks. Alright. Thank you.
Speaker 0: Awesome. Thank you. Hopefully, we’ll see you at connections.
Speaker 1: Yeah. Yeah. Hopefully. Cheers. Bye bye. Bye bye. Bye.