1

There are a few similar articles about this topic but I haven't found the exact answer I'm looking for.

I have a dynamic link in an email that needs to be tracked.

When I preview and run a test send without tracking, the links render correctly with '?utms' etc. When tracking is applied they break and direct to https://click.email.thehomelike.com/utm_source...

Here's an example of the AMPscript I'm using:

%%[SET @apt_alt_1_image = Pre_Platform_Inquiry__c:First_Apartment_Alternative__r:Link__c]%%

<a href="%%=RedirectTo(@apt_alt_1_image)=%%?om_cmpgn=%%emailname_%%&utm_cmpgn=%%utm_cmpgn%%&om_medium=email&utm_term=apt_alt_1_image"

I should note that "Pre_Platform_Inquiry__c:First_Apartment_Alternative__r:Link__c" is a value in the Data Extension that is a complete link already, like "https://app.thehomelike.com/apartment/d49a3c45c2f0fc15ef0f"

There's a paragraph on https://ampscript.guide/redirectto/ that states: "If the RedirectTo function is not used in the href attribute when an attribute or variable is used, the hyperlink will not be resolved with the attribute or variable, for example it will appear as, https://click.email.com/%%=v(@url)=%%." I don't fully understand what this means and if it's related.

Any assistance is appreciated.

2 Answers 2

5

Firstly, I would use Concat function if I were you. Just adding a number of AmpScript blocks within a single string doesn't work. Secondly, there is no such substitution string as utm_cmpgn - so in my review, I included this as a string. What is your intent to use instead of that? You can find the emailname_ and other personalisation strings here. These do not need to be initialised, but can be called directly. Observe these don't need to be prepended with @ - this applies only for variables.

As Gortonington rightfully states in his comments, you should use AttributeValue function when referencing data extension fields - for improve error handling.

Please see the updated code below:

%%[
SET @apt_alt_1_image = AttributeValue("Pre_Platform_Inquiry__c:First_Apartment_Alternative__r:Link__c")
SET @link = Concat(@apt_alt_1_image,'?om_cmpgn=',emailname_,'&utm_cmpgn=utm_cmpgn&om_medium=email&utm_term=apt_alt_1_image')]%%

<a href="%%=RedirectTo(@link)=%%">Link</a>
4
  • 1
    Too quick for me @LukasLunow. I was literally just typing up the same things. One note is I would declare the personalization strings (especially if they are coming from a DE, not the default ones) via the AttributeValue() function for better null handling. May 7, 2019 at 15:04
  • 1
    That was a cheap one for me, @Gortonington. Thanks for the upvote -> good sportsmanship there. Added AttributeValue() - thanks for the heads-up May 7, 2019 at 15:05
  • 1
    Here's another one from me for being quick on the draw @LukasLunow May 7, 2019 at 15:06
  • Please don't forget to mark the answer as accepted, if this has been helpful May 8, 2019 at 11:52
1

You need to concatenate your parameters onto the URL and then call the entire URL in RedirectTo. So something like this:

    %%[
    SET @apt_alt_1_image = Pre_Platform_Inquiry__c:First_Apartment_Alternative__r:Link__c
    SET @concat_url = CONCAT(@apt_alt_1_image,"?om_cmpgn=",emailname_,"&utm_cmpgn=",@utm_cmpgn,"&om_medium=email&utm_term=apt_alt_1_image")
    ]%%

    <a href="%%=RedirectTo(@concat_url)=%%">Link</a>
4
  • thank you! For values like %%emailname_%% which are system variables, would I need to define the variable like SET @ emailname = %%emailname_%% or can it be placed in the concat_url as "?om_cmpgn="%%emailname%%"? May 7, 2019 at 15:35
  • 1
    I always set all values that will be used within the email send just to be sure, but you do not have to set those standard personalization strings before you call them in your ampscript block. Also, in the concat function, do not use those percents like that. Just call it as "emailname_" in it's own comma separated argument and leave off those symbols. May 7, 2019 at 15:51
  • 1
    @JasonHanshaw - please do observe, you are referencing utm_cmpgn as if it was a valid personalisation string, which it isn't May 7, 2019 at 15:53
  • 1
    Yep, you're right, this is not a personalization string. I've updated to make that a bit more obvious. Thanks! May 7, 2019 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .