So we have a url that is pulled in dynamically from a lookup Data Extension(Data Table). It is structured like this: https://www.clientsite.com/on-boarding/#anchorlocation. However, when we test send the email and click the link we go to the page but the anchor does not take you to the linked anchor location. Come to find out after investigating that once we removed the tracking parameters from the end of the url it worked just as intended because it was the original url. However, we need the tracking so removing the tracking is not an option. So, what is the issue? Here is an example of the code:
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="middle" align="center">
<a alias="%%=v(@Alias)=%%" href="%%=RedirectTo(@URL)=%%" target="_blank"><img alt="" border="0" src="%%=v(@VideoImage)=%%" style="display:block;" title="" width="100%" /></a></td>
</tr>
</table>
Here is an example of the url once the email was sent. This link would go to the page but not to the anchored section of the page:
So, after some time I did find out what is going on and how to fix it. It appears that the anchor name must be at the end of the url. So it should look like this:
Here is how I accomplished that with our dynamic content. I know what the tracking parameters are and where the data comes from to populate them. So I simply had to use the Ampscript Concat function to rearrange the url. Here is an example of that code:
%%[
/* This is pulled from the DE or Data Table */
Set @URL = '#anchorlocation'
/* This resets the variable to the rearranged url */
Set @URL = Concat('https://www.clientsite.com/on-boarding/?utm_source=',__AdditionalEmailAttribute1,'&utm_medium=email&utm_term=',__AdditionalEmailAttribute2,'&utm_content=Alias&utm_campaign=',emailname_,@URL) ]%%
Then when I call the variable in the code I need to concat the html for the anchor and image tags so that the tracking will not be put on it a second time. That code looks like this:
%%=concat('<a alias="',@Alias,'" href="',@URL,'" target="_blank"><img alt="" border="0" src="',@Image,'" style="display:block;" title="" width="100%" /></a>')=%%
Put that together and the entire code looks like this:
%%[ Set @URL = Concat('https://www.clientsite.com/on-boarding/?utm_source=',__AdditionalEmailAttribute1,'&utm_medium=email&utm_term=',__AdditionalEmailAttribute2,'&utm_content=Video_Alias&utm_campaign=',emailname_,@URL) ]%%<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#E8E8E8">
<tr>
<td style="line-height:1px; font-size:1px;" height="1" bgcolor="#DEDEDE"> </td>
</tr>
<tr>
<td valign="top" bgcolor="#E8E8E8" align="left">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="middle" align="center">%%=concat('<a alias="',@Alias,'" href="',@URL,'" target="_blank"><img alt="" border="0" src="',@Image,'" style="display:block;" title="" width="100%" /></a>')=%%</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="line-height:1px; font-size:1px;" height="1" bgcolor="#DEDEDE"> </td>
</tr>
</table>