cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
steveshe
Frequent Visitor

How do I get flow to stop encoding the ampersand in the href in my anchor tag?

How do I stop Flow from encoding an ampersand in a link in the body of my message?

 

I am sending HTML email and in that mail I want to embed a google analytics link, but it wont work because Flow keeps encoding the ampersand ( & ) to ( & ) which breaks the URL.

 

Here is a sample:

 

href="https://www.google-analytics.com/collect?v=1&tid=UX-1345610741-1&cid=XYZ&t=event&ec=email&ea=open&el...

 

 

But if you look at the source in the body of the mail, it has clearly encided the "&" to be "&":

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
Hello,<br>
<br>
<a href="https://www.google-analytics.com/collect?v=1&amp;tid=UX-1345610741-1&amp;cid=XYZ&amp;t=event&amp;ec=...>
</body>
</html>

 

 

Principal Escalation Engineer
Customer Service & Support (CSS)
Microsoft Services
1 ACCEPTED SOLUTION

Accepted Solutions
steveshe
Frequent Visitor

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

Since I was able to find the root cause of the problem I wanted to come back here and close this out. The encoding seems to be specific to the Outlook Client. Outlook web mail works fine for both Outlook.com and Office365. Ultimately it is Word that provides the HTML functionality in Outlook so getting to the bottom of it is probably more work than it is worth, especially considering that the whole point of this exersize was to enable Google Analytics Event Tracking in emails, which relies on the mail client retrieving an image of a 1x1 pixel from GA. The default setting in Outlook Client is to block images / image tags so that will never work anyway, even if Outlook encoided the image tag query parameters correctly. 

Principal Escalation Engineer
Customer Service & Support (CSS)
Microsoft Services

View solution in original post

11 REPLIES 11
Super User
Super User

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

IsHTML.PNG

Did you set Is HTML to Yes?

Highlighted
steveshe
Frequent Visitor

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

Yes. If you dont do that, then I'm pretty sure you just get the HTML as text and no encoding or unencoding happens. 

Principal Escalation Engineer
Customer Service & Support (CSS)
Microsoft Services
steveshe
Frequent Visitor

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

Sorry Peter, I just realized from my post you might think that I was getting raw HTML in the visibile portion of the email. That is not the case. I just did a View Source on the email and posted the unrendered HTML body for expositive purposes. It all renders correctly, but the link doesn't work because Google Analytics doesn't understand "&amp;" as an argument seperator.

 

I need the "&" in the href to be rendered into the body of the email unencoded. 

Principal Escalation Engineer
Customer Service & Support (CSS)
Microsoft Services
Super User
Super User

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

Hi @steveshe,

 

I tried sending an email with html and a href that included &s and it just worked. can you copy paste your email body (from the action) into notepad? This creates the exact detailed code and then DM it to me. 

steveshe
Frequent Visitor

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

I just sent it. I think it worked at one point but i can;t figure out what broke it or how to fix it. Let me know if you can see it.

Principal Escalation Engineer
Customer Service & Support (CSS)
Microsoft Services
steveshe
Frequent Visitor

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

I just remembed. I changed the email connector from Outlook.com to Office 365. I had apparently not been paying attention when I filtrered email actions on "Send an Email" and I accidentally selected the Outlook.com conenctor instead of Office 365. It worked, but it caused my flow to get suspended because we have a policy against connecting corporate BI to Outlook.com email. I redid the flow to use Office365 and I think it was after that when I noticed that the link was broken. 

 

Which email connector are you using in your test?

Principal Escalation Engineer
Customer Service & Support (CSS)
Microsoft Services
Super User
Super User

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

FastCars.PNG 

Here is my example. I went to google searched for fast cars. Then I copeid the url to my email body and replaced my query string with the variable. I'm getting an email with the right link in it.

steveshe
Frequent Visitor

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

I did it exactly as you did and i get this:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<a href="https://www.google.com/search?q=fast&#43;carsFast Cars&amp;rlz=1C1CHBF_enUS731US731&amp;oq=fast&#43;carsFast Cars&amp;aqs=chrome..69i57j0l2j69i60j0l2.1875j0j8&amp;sourceid=chrome&amp;ie=UTF-8">click link</a>
</body>
</html>

 

I am starting to think this a problem with Office 365 Mail... I will test with Outlook.

Principal Escalation Engineer
Customer Service & Support (CSS)
Microsoft Services
steveshe
Frequent Visitor

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

Same thing using an Outlook send mail task. I am stumped...

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<a href="https://www.google.com/search?q=fast&#43;carsQuery&times;&#8203;&amp;rlz=1C1CHBF_enUS731US731&amp;oq... link</a>
</body>
</html>

Principal Escalation Engineer
Customer Service & Support (CSS)
Microsoft Services
Community Support
Community Support

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

Hi @ steveshe,

 

Are you still having this issue now?

 

If you issue still exists, please share a screenshot of the configuration of your flow, so I could try to help you.

 

As @ Pieter_Veenstra’s test, I have made a test on my side and don’t have the issue that you mentioned.

The link with “&” always work well on both “Outlook.com” and “Office 365 Outlook” Connector.

 

 

Regards,
Alice Zhang

steveshe
Frequent Visitor

Re: How do I get flow to stop encoding the ampersand in the href in my anchor tag?

Since I was able to find the root cause of the problem I wanted to come back here and close this out. The encoding seems to be specific to the Outlook Client. Outlook web mail works fine for both Outlook.com and Office365. Ultimately it is Word that provides the HTML functionality in Outlook so getting to the bottom of it is probably more work than it is worth, especially considering that the whole point of this exersize was to enable Google Analytics Event Tracking in emails, which relies on the mail client retrieving an image of a 1x1 pixel from GA. The default setting in Outlook Client is to block images / image tags so that will never work anyway, even if Outlook encoided the image tag query parameters correctly. 

Principal Escalation Engineer
Customer Service & Support (CSS)
Microsoft Services

View solution in original post

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Users online (7,694)