Here’s the scenario. We had links where the URL was populated from the data. The field was called “URL”, and it contained URLs without the http://.
So, my code looked like this:
Pretty straight forward.
Well, the data extension that was used for the email send, would get updated after the blast. What we found out is the when someone clicks on the link from their email they received, it talks back to the data extension to get that URL. So, if the DE was updated with a different URL, or no URL, the link didn’t work anymore. Not good.
So, ExactTarget suggested using AMPscript to fix this. The fix was using the RedirectTo function. I was instructed to fist assign the URL field to a variable, and then wrap the variable in the RedirectTo function.
My code now looked like this:
%%[ Set @url = URL ]%%
This worked, and all was good.
I started another project that also used a URL from the data, and the data was going to be frequently updated, so I used this same approach. But, it didn’t work anymore. This was bad.
The link would not redirect. It would get hung up on the tracking URL and stop there. I called ExactTarget and they opened a case and worked on a fix. After called back a couple of days later, I new fix for the fix was discovered. For some reason, having the http:// hard coded in the HTML was not letting it redirect.
My new, and final code, looked like this:
Set @url = URL
Set @complete_url = Concat("http://",@url)
<a href="%%=RedirectTo(@complete_url)=%%"> v(@url)=%%</a>
It was really frustration, but I enjoy working with AMPscript, so every challenge results in learning, and a greater understanding of the code, and the system.