# Segment mails Site-URL using {webview\_url} and {tracking\_pixel}

**URL:** <https://forum.mautic.org/t/segment-mails-site-url-using-webview-url-and-tracking-pixel/23612>\
**Category:** Product Support\
**Created:** [April 6, 2022, 10:58am UTC](https://forum.mautic.org/t/segment-mails-site-url-using-webview-url-and-tracking-pixel/23612 "2022-04-06T10:58:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milenco](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/milenco/32/6298_2.png) [@Milenco](https://forum.mautic.org/u/Milenco)\
**Post date:** [April 6, 2022, 10:58am UTC](https://forum.mautic.org/t/segment-mails-site-url-using-webview-url-and-tracking-pixel/23612/1 "2022-04-06T10:58:12Z")

</div>

**Your software**  
Server: Linux xxx 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86\_64  
My Mautic version is: 4.2.1 (upgraded from 4.0.x)  
My PHP version is: 7.4.28  
My Database type and version is: 10.5.15-MariaDB-0+deb11u1

**Your problem**  
My problem is:  
We have setup our Site-URL to “[https://mautic.domain.com/](https://mautic.domain.com/)”. This domain however isn’t always properly used. See this example:

1. I create a new segment mail, using a theme which utilizes {webview\_url} and {tracking\_pixel}.
2. I save and close the e-mail.
3. The “Preview URL” for some mails show the IP address of our domain ([https://10.10.x.x/email/preview/x](https://10.10.x.x/email/preview/x)) instead of the Site-URL.
4. I send an example to myself. The {webview\_url} and {tracking\_pixel} fields are correctly substituted by the Site-URL.
5. I send the actual e-mail. The {webview\_url} and {tracking\_pixel} fields are **not** correctly substituted by the Site-URL. They instead show a URL to [https://10.10.x.x/](https://10.10.x.x/).
6. After I send the e-mail, the “Preview URL” in Mautic now shows the actual Site-URL) ([https://mautic.domain.com/email/preview/x](https://mautic.domain.com/email/preview/x))

The logs don’t show any issue. I have cleared the cache, both using ‘php bin/console cache:clear’ and ‘rm -rf var/cache/\*’.

Also verified that my config/local.php site\_url is set up correctly. In the database or the mautic folder I can find no reference to our internal IP address.

I would like to prevent having to do a clean install, is there any way to fix this issue? I recently upgraded to 4.2.1 but also had this issue in older versions. I’ve upgraded from 4.0.2.

---

<div class="post-metadata">

**Author:** ![Milenco](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/milenco/32/6298_2.png) [@Milenco](https://forum.mautic.org/u/Milenco)\
**Post date:** [April 6, 2022, 1:12pm UTC](https://forum.mautic.org/t/segment-mails-site-url-using-webview-url-and-tracking-pixel/23612/2 "2022-04-06T13:12:40Z")

</div>

I did some more research and found someone else with this issue: [Segment Mails do not use site\_url (better version) · Issue #10137 · mautic/mautic · GitHub](https://github.com/mautic/mautic/issues/10137)

Apparently Mautic doesn’t use the site\_url in the configuration when sending out Segment mails. Instead, it’s uses the URL the admin is using to access Mautic and start the Segment mail (in my case, 10.10.x.x instead of [mautic.domain.com](http://mautic.domain.com)). We are using our Mautic instance behind a reverse proxy. I’ll try to change it there so this proxy addresses the Mautic instance by it’s FQDN instead of IP-address.

EDIT: I can confirm this is the issue. My reverse proxy was accessing the Mautic instance on [https://10.10.x.x/](https://10.10.x.x/) instead of [https://mautic.domain.com/](https://mautic.domain.com/)). This causes Mautic to use that URL (instead of site\_url specified in the configuration) for links in Segment mails. It doesn’t happen on sending examples, but when actually sending the e-mails the problem occurs. Now that I’ve changed my reverse proxy (by adding a manual entry for [mautic.domain.com](http://mautic.domain.com) to 10.10.x.x) to access the Mautic instance on the FQDN-URL, the issue is resolved.

---

<div class="post-metadata">

**Author:** ![ilo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ilo/32/1181_2.png) [@ilo](https://forum.mautic.org/u/ilo)\
**Post date:** [May 20, 2022, 1:56pm UTC](https://forum.mautic.org/t/segment-mails-site-url-using-webview-url-and-tracking-pixel/23612/3 "2022-05-20T13:56:27Z")

</div>

Hi @Milenco,  
I think I am having the same issue as you. I am also using the Mautic instance behind a reverse proxy. But I don’t really understand your solution. Could you please explain again what exactly did you do in order to fix the problem? What do you mean by “adding a manual entry”? Thanks!

---

<div class="post-metadata">

**Author:** ![Milenco](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/milenco/32/6298_2.png) [@Milenco](https://forum.mautic.org/u/Milenco)\
**Post date:** [May 24, 2022, 1:13pm UTC](https://forum.mautic.org/t/segment-mails-site-url-using-webview-url-and-tracking-pixel/23612/4 "2022-05-24T13:13:06Z")

</div>

Hello @ilo,

Sorry for the delayed response.

So, in my case, my reverse proxy is a Windows Server machine running IIS. The problem is that IIS is accessing Mautic through [http://10.10.10.123](http://10.10.10.123) instead of [http://mautic.domain.com](http://mautic.domain.com). This URL is used in the webview\_url and tracking\_pixel shortcuts.

To prevent this, you need to have IIS access your Mautic instance through [mautic.domain.com](http://mautic.domain.com) (instead of the IP directly). But, because [mautic.domain.com](http://mautic.domain.com) translates to a public IP-address, your IIS instance needs to be tricked to access the DNS-name through it’s local IP-address. To do so, edit C:\Windows\system32\drivers\etc\hosts and add a line for [mautic.domain.com](http://mautic.domain.com) which has Mautics local IP in it.

---

<div class="post-metadata">

**Author:** ![ilo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ilo/32/1181_2.png) [@ilo](https://forum.mautic.org/u/ilo)\
**Post date:** [May 25, 2022, 7:42am UTC](https://forum.mautic.org/t/segment-mails-site-url-using-webview-url-and-tracking-pixel/23612/5 "2022-05-25T07:42:08Z")

</div>

Hi @Milenco,  
Thank you for your answer.  
In my case, I’ve finally fixed my issue by adding $\_SERVER[‘HTTP\_HOST’] = ‘_mautic.domain_’ in index.php. Otherwise, all my segment emails were sent with links being overwritten by reverse proxy’s url instead of Mautic’s site\_url.
