Tracking your links is one of the MOST important parts of building an email. So it should come as no surprise that everyone who has worked in email for a long time has stories of when things went wrong. I know that I have faced plenty of these issues in my email career – everything from CTA’s without any tracking, spaces or other illegal characters breaking the URL, missing parameters, and even passing the wrong information. Tracking is such a vital piece that when it is wrong or broken or missing, it can wreak havoc on the analytics and make tracking the email’s success a lot tricker.
I’ve learned that if you are building your links out each time you have a link in your email, you have that many more places where human error could cause an issue with the tracking. The most common human error I have seen is that the tracking information is either incorrect or missing parameters.
These issues tend to come in a couple of categories –
- Information from an old email – usually caused because you duplicated an old email
- Incorrect parameter name – if you are using multiple systems, you might need to pass the campaign id with the parameter name of campaignid for one system and cid for another.
- Missing parameters – one or more of the pieces collected by the cta page is missing.
The good news is that there is a solution that will make it much easier to avoid these issues – Dynamic tracking strings.
One of the most powerful tools you have at your fingertips in SFMC is AMPscript. AMPscript is evaluated person by person and email by email. With AMPscript, you can save a value as a variable and then use that variable in multiple places and pull in the value set.
So what if instead of setting your tracking information on each link one at a time, you set it up once at the beginning of your email and then used that value over and over again?
How this works is – you create a variable, save your tracking information to that variable, and then add that variable to the end of each of your links. Simple enough, right? But why stop there? With ampscript, we can pass lots of dynamic variables as parameters on your URLs; we just need a way to string them all together. That is where Concat() comes in.
Concat(), if you haven’t used it yet, is set up to allow you to take multiple pieces and merge them into one single string.
DEFINITION OF PARTS —
1= This is the 1st string.
2= This is the 2nd string.
The strings can be passed as [attribute value], @variable, or in “string format”. There is no limit to how many strings you have within the AMPscript Concat() function.
Check out our previous post on Concat() for some Simple Examples and uses cases around a person’s full name and address.
Advanced Use Case – Using Concat to create a tracking string.
%%[/* Values that change email to email - I put this in an AMPscript block above my header*/ set @emailname="123-Welcome3" set @CampaignID=[CampaignID] /*Values that either do not change or get pulled in the same way for every email - I include this at the begining of my header block*/ set @senddate=Format(Now(),'yyyy-MM-dd') set @sfid=[salesforceid] /*Pulling all the pieces together into one string - This needs to be below all the set functions, as you want there to be a value on the variable before you use it - I include this in my header block before any URL's */ set @Tracking = concat("cid=",@CampaignID,"&senddate=", @senddate,"&eml_name=",@emailname, "&sfmc_s=",@sfid,"&source=email&medium=email")
]%%<a href="https://sfmcgeeks.com/?%%=v(@tracking)=%%"> This is my link </a>
Advanced Use Case – Having multiple tracking string variations. For instance – if you send to your site, you want to collect specific information, whereas if you send to your survey platform – they only get some of the information.
%%[/* Uses same SET functions for the data pieces as notated above*/ /*Pulling all the pieces together into one string */ /*Version 1 = Our site tracking*/ set @OurTracking = concat("cid=",@CampaignID,"&senddate=", @senddate,"&eml_name=",@emailname, "&sfmc_s=",@sfid,"&source=email&medium=email") /*Version 2 = Survey Platform tracking*/ set @SurveyTracking = concat("cid=",@CampaignID,"&sfid=",@sfid,"&source=email&language=en")
]%%<a href="https://sfmcgeeks.com/?%%=v(@ourtracking)=%%"> This is a link to our site</a> <a href="https://surveyplatform.com/?%%=v(@surveytracking)=%%"> This is a link to our survey platform</a>
Advanced Use Case – Using Concat() to build the link as well.
%%[ /* Uses same SET functions for the data pieces as notated above*/ /* Uses same SET functions for the tracking pieces as notated above*/ set @rawctalink="https://sfmcgeeks.com/?" set @finalctalink=concat(@rawctalink,@ourtracking) ]%% To use a URL that you have set on a AMPscript variable you will need to pair it with RedirectTo like this: <a href"%%=RedirectTo(@finalctalink)=%%> CTA Text </a>
Couple of reminders:
- Ensure you understand what each parameter should be called and if it is a dynamic value that will need to be passed as a variable or a static value.
- Make sure your URL is formatted correctly.
- Only 1 “?” before all the parameters
- Each additional parameter is prefixed with an “&”
- This does NOT eliminate the need to QA your links in your email. If this is broken, it would be broken in ALL the links, making it a little easier to catch.