I am trying to write an inline IFF statement for use in our Web Analytics Connector parameter string. Currently I have the following:

...&utm_content=%%=iif(IndexOf("%%linkname%%","http")>0,"unknownlink", "%%linkname%%")=%%

When an explicit Link Name has not been set for a link, the full http.... web address renders in the url as the utm_content value. This breaks our website. So the point of the IFF is to check if %%linkname%% is actually a http web address, then just put "unknownlink" instead.

I have done a lot of testing on this and it seems to work well.

However, now I am trying to also handle links that are an ampscript function. For example, if using a RedirectTo function, then the utm_content paramter value renders in the url as literally %%=RedirectTo(......)=%% which is no good.

So I want to add in an OR to handle both "http" and "%%=" values. But I can't figure out how to do an inline IFF OR statement. I have tried the following:

 ...&utm_content=%%=iif((IndexOf("%%linkname%%","http")>0 OR IndexOf("%%linkname%%,"%%=")>0),"unknownlink", "%%linkname%%")=%%


...&utm_content=%%=iif(or(IndexOf("%%linkname%%","http")>0,IndexOf("%%linkname%%,"%%=")>0),"unknownlink", "%%linkname%%")=%%

Neither work. Anyone know how to do this or if it's possible?

Adding some additional info for context

What we are trying to do is be able to track performance of dynamic content in GA. So we are using utm_content as a url analytics parameter and then trying to populate this with the Tracking Alias (%%linkname%%) for GA to use.

However, we would only input a tracking alias value when required (eg: on dynamic content) and leave all other links blank. In this scenario, all other links would result in the entire url of said link being rendered in the resulting url as a parameter value. This breaks out website.

So I am trying to solve for a way to prevent this. Over many long discussions with Salesforce, there didn't seem any known way to do this. Their only suggestion was to put ampscript (like what I am trying to do) in the WAC string to check if a fully formed url was being set as %%linkname%% and overriding this with a simple text string. I did not want to do this initially since in the event any issues arose only support could change the WAC string. Now that admins can edit the WAC string, I am open to putting ampscript in there.

  • for the last line: there is no OR() function in AMPScript. Atleast not in the function reference. Mar 30, 2020 at 11:09
  • Another comment: By the time you executed this script the %%linkname%% might already be executed, that is why you maybe won't find this succeding Mar 30, 2020 at 11:13
  • Another thing: %%linkname%% will not use the url of the link but the tracking alias. Its not good idea to have the tracking alias as an URL but rather something like a position or content description. Mar 30, 2020 at 11:18
  • Thanks. You can use OR in ampscript, even though I can't find it documented anywhere. It does work correctly with my current version (first code snippet) so all good there. Finally, the issue with personalisation string %%linkname%% is that if no Tracking Alias value has been set then it defaults to the full url, which is what I am trying to avoid.
    – Ben
    Mar 30, 2020 at 21:31
  • Sorry re being able to use OR I meant you can use it but I think you are right in that there is no actual OR() function.
    – Ben
    Mar 30, 2020 at 21:40

1 Answer 1


As @Johannes suggested, linkname is substituted at the same time the AMPscript is evaluated.

I'd recommend utilizing AttributeValue, which will return an empty string if there the substitution string that doesn't exist.

%%=iif(IndexOf(AttributeValue("linkName"),"http") > 0 OR empty(AttributeValue("linkName")), "unknownlink", AttributeValue("linkName"))=%%
  • This would also result in changing links that include http somewhere (for example parameters, accidental hashes, ...). Wouldn't it be better to search for "http" only at the start of the linkName? Mar 30, 2020 at 13:40
  • Thanks Adam. That doesn't work unfortunately as now even if there is a Tracking Alias value, I still get "unknownlink" as a result. I recall when speaking to SF that the %%linkname%% personalisation string behaves differently in that it does not execute at send time but rather when a link is clicked. Maybe that is why?
    – Ben
    Mar 30, 2020 at 21:53
  • How are you testing it? Mar 30, 2020 at 22:04
  • I am updating the WAC String (since we can do that ourselves now) and then sending a test email I have setup with some dynamic content, some RedirectTo links, etc.
    – Ben
    Mar 31, 2020 at 2:26
  • RedirectTo links end up like this in the url: &utm_content=%%%3dRedirectTo(CloudPagesURL(000))%3d%% which breaks our site
    – Ben
    Mar 31, 2020 at 2:39

You must log in to answer this question.

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