Ampersands in URL being escaped to &

Fraser Or asked on January 26, 2022 22:05

I need to include a link go google analytics (in this case in an email Kentico is generating):

I have this (you will see I tried a few different options): (Note AppSettingValue is a macro to pull something from the web.config.)

<img src="https://www.google-analytics.com/collect?tid=1234&cid=456&t=event&ec=event" />
<img src='https://www.google-analytics.com/collect?tid=1234&cid=456&t=event&ec=event' />
<img src='{%"https://www.google-analytics.com/collect?tid=1234&cid=456&t=event&ec=event" #%}' />
<img src='{%"https://www.google-analytics.com/collect?tid=1234&cid=456&t=event&ec=event" |(encode)false #%}' />

However, in the resulting email the & characters, which are supposed to separate the fields, are being escaped to &

<img src="https://www.google-analytics.com/collect?tid=1234&cid=456&t=event&ec=event">
<img src="https://www.google-analytics.com/collect?tid=1234&cid=456&t=event&ec=event">
<img src="https://www.google-analytics.com/collect?tid=1234&cid=456&t=event&ec=event">
<img src="https://www.google-analytics.com/collect?tid=1234&cid=456&t=event&ec=event">

I'm not sure how to fix this. (Yes, I am a newbie, so your help would be appreciated.)

Context: this is MVC, version is 11.0.49 and the code above is in a Marketing Email Template.

Recent Answers


Juraj Ondrus answered on January 27, 2022 05:22

Where and how are you entering this HTML code? What version and development model are you using?

0 votesVote for this answer Mark as a Correct answer

Fraser Or answered on January 27, 2022 17:44

Juraj Ondrus, I answered your question by adding a context at the bottom of my question. Thanks.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 28, 2022 07:01

How are you editing the email template? I have added the code like this and then when I sent the newsletter based on that template, the email looks like this. I do not see any issues.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.