spatie / mailcoach-support

Questions and support for Mailcoach
https://mailcoach.app
31 stars 2 forks source link

Links clicked appended by wrong characters #206

Closed mabadir closed 4 years ago

mabadir commented 4 years ago

Hello,

When checking the clicks for a campaign campaigns/{id}/clicks, I see that the links are appended by wrong characters, mainly brackets ")".

I am not sure where to start from to track this problem.

freekmurze commented 4 years ago

I'm pretty sure this is caused by something specific to your installation, as you are the first to report this.

Right now, there's too little information to help you. Could you give us as much info as possible:

mabadir commented 4 years ago

Hi Freek, Thanks for your response, just to clarify, I am not seeing that on the email client. Those are the links stored under clicks. I can see them in the database under mailcoach_campaign_links.url. I cannot replicate this issue even on the same installation. It happened to one campaign using specific HTML email. Other campaigns using the same template work fine.

This campaign was using SendGrid. And here is an example link: https://www.kivbroker.com/img/jb.jpg) I do not have this link in my HTML, this is an img src but without that trailing bracket.

Below the HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta content="telephone=no" name="format-detection" />
    <title>Kiv Broker Launched</title>
    <style type="text/css" data-premailer="ignore">
        @import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,600,700);
    </style>
    <style data-premailer="ignore">
        @media screen and (max-width: 600px) {
            u+.body {
                width: 100vw !important;
            }
        }

        a[x-apple-data-detectors] {
            color: inherit !important;
            text-decoration: none !important;
            font-size: inherit !important;
            font-family: inherit !important;
            font-weight: inherit !important;
            line-height: inherit !important;
        }
    </style>
    <!--[if mso]>
      <style type="text/css">
        body, table, td {
            font-family: Arial, Helvetica, sans-serif !important;
        }

        img {
            -ms-interpolation-mode: bicubic;
        }

        .box {
            border-color: #eee !important;
        }
      </style>
    <![endif]-->
    <link rel="stylesheet" href="https://www.kivbroker.com/emails/welcome/assets/theme.css" />
</head>

<body class="bg-body">
        <table class="main bg-body" width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <td align="center" valign="top">
                    <!--[if (gte mso 9)|(IE)]>
              <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="center" valign="top" width="640">
            <![endif]-->
                    <span class="preheader">Welcome to Kiv Broker.</span>
                    <table class="wrap" cellspacing="0" cellpadding="0">
                        <tr>
                            <td class="p-sm">
                                <table cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td class="py-lg">
                                        </td>
                                    </tr>
                                </table>
                                <div class="main-content">
                                    <table class="box" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td>
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td class="content pb-0" align="center">
                                                            <table class="" cellspacing="0" cellpadding="0">
                                                                <tr>
                                                                    <td valign="middle" align="center">
                                                                        <img src="https://www.kivbroker.com/img/logo.svg" class=" va-middle" width="150" alt="type" />
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                            <h1 class="text-center m-0 mt-md">We just launched <a href="https://www.kivbroker.com">Kiv Broker</a>, a marketplace for financial services professionals</h1>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="content text-wrap">
                                                            <p>Good morning ::subscriber.first_name::,</p>
                                                            <p>My name is John Bernard Duler and I want to introduce you to <a href="https://www.kivbroker.com">Kiv Broker</a>.</p>
                                                            <p><a href="https://www.kivbroker.com">Kiv Broker</a> is a marketplace for professionals in financial services who want to:</p>
                                                            <ul>
                                                                <li>get more leads</li>
                                                                <li>refer smart professionals to their clients</li>
                                                            </ul>
                                                            <p>This email is a call to you: insurance brokers, corporate lawyers, RIAs, payroll experts, bankers, mortgage brokers, or valuation experts.</p>
                                                            <p>You serve customers in a specific industry, you live in a specific area. And you’ve got specific knowledge.</p>
                                                            <p>If your customer base shrank during this economic collapse, you need to find new clients now.</p>
                                                            <p>But you can also help others as you deal with clients every day: please refer deals too small for you, or not in your area of expertise, or not in a state you are licensed in.</p>
                                                            <p>A bit about <a href="https://www.kivbroker.com/about">me</a></p>
                                                            <ul>
                                                                <li>I served as an executive with AXA/Equitable, CIGNA and Chubb.</li>
                                                                <li>In 1998 I founded Esurance, now with $2B in revenues, and served as its first CEO.</li>
                                                                <li>I later built a consulting and brokerage firm, which I sold 10 years later to AJ Gallagher.</li>
                                                                <li>Over 30 years, I sold services and, as a CEO or COO, I also bought services from accountants, lawyers, insurance brokers and financial advisors.</li>
                                                                <li>My major at Wharton was finance and entrepreneurship.</li>
                                                            </ul>
                                                            <p>This is an industry I love deeply and have enjoyed over the years, both in the US and in Europe. I am profoundly saddened to witness the distress of friends who have worked so hard over so many years to build a practice around a client base that has disappeared overnight.</p>
                                                            <p>
                                                                Building trust, knowledge, experience and a strong network are the pillars of professionals such as you. Today I invite you, ::subscriber.first_name::, to browse thousands of deals already on <a href="https://www.kivbroker.com/marketplace">Kiv Broker</a> (we have been working in secrecy for a while with a handful of dedicated professionals).
                                                            </p>
                                                            <p>Cheers,</p>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="content pt-0">
                                                            <table cellspacing="0" cellpadding="0">
                                                                <tr>
                                                                    <td class="va-top pr-md w-1p">
                                                                        <img src="https://www.kivbroker.com/img/jb.jpg" class=" avatar " width="48" height="48" alt="" />
                                                                    </td>
                                                                    <td class="va-middle">
                                                                        John Bernard Duler<br />
                                                                        <span class="text-muted">Founder and CEO<br />Kiv Broker<br/>Sausalito, California</span>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <table cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td class="py-xl">
                                            <table class="font-sm text-center text-muted" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td class="px-lg">
                                                        If you have any questions, feel free to message us at <a href="mailto:support@kivbroker.com" class="text-muted">support@kivbroker.com</a>.
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="px-lg">
                                                        Kiv Broker - 150 Harbor Drive # 564 - Sausalito CA 94965
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="pt-md">
                                                        <a href="::unsubscribeUrl::" class="text-muted">Unsubscribe</a>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <!--[if (gte mso 9)|(IE)]>
            </td>
          </tr>
        </table>
            <![endif]-->
                </td>
            </tr>
        </table>
</body>

</html>
rubenvanassche commented 4 years ago

Hi @mabadir,

Tried recreating this issue but couldn't, I have tried this with SendGrid. Mailcoach normally won't replace these links(unless you've added an extra replacer), this is handled by the transactional mail providers like Mailgun and Sendgrid. Which transactional provider are you using? Is there maybe a setting over there where this goes wrong?

electronick86 commented 4 years ago

I have the same problem. I only use sendgrid. Maybe it comes from the sendgrid side.

rubenvanassche commented 4 years ago

@electronick86 Is it possible for you to check Sendgrid for settings that could cause this? And do you have an example of an Url that get's the wrong clicks? Maybe we can find some pattern?

electronick86 commented 4 years ago

So, 3 things,

I wonder if there is not something wrong at the sendgrid side. But in the configuration, I don't see any settings for that.

Clicks___7Dimanche_EDITION_NON_CONNUE_2020-06-28___7Dimanche_Mailing

[{"email":"xxxxxx","event":"click","ip":"212.xxx.yyy.zzz","send_uuid":"a1496fde-6779-40ff-bff7-ad562b10a128","sg_event_id":"Lfnr7qphr2Ipk1Q","sg_message_id":"yP-6vHloRg.filterdrecv-p3iad2-5b5v6r54-19-5EF84758-36.0","timestamp":1593329556,"url":"https:\/\/my_cdn_domain\/template_mail\/header-7D.png)","url_offset":{"index":0,"type":"text"},"useragent":"Mozilla\/5.0 (Windows NT 6.3; Trident\/7.0; rv:11.0) like Gecko"}]
rubenvanassche commented 4 years ago

Hi guys, I still looked for aw while where this could be going wrong but couldn't find it. I would try for you guys to check the ClickEvent file in vendor/spatie/laravel-mailoach-sendgrid-feedback. Maybe you could add some logging temporarily to the handle function where you log the payload coming from Sendgrid? Because from that point the url passes through this piece of code:

        if (! $this->campaign->track_clicks) {
            return null;
        }

        if (Str::startsWith($url, route('mailcoach.unsubscribe', ''))) {
            return null;
        }

        $campaignLink = CampaignLink::firstOrCreate([
            'campaign_id' => $this->campaign->id,
            'url' => $url,
        ]);

Which cannot change the url with an extra ). Another possible problem I see is that the model info @electronick86 provided:

[{"email":"xxxxxx","event":"click","ip":"212.xxx.yyy.zzz","send_uuid":"a1496fde-6779-40ff-bff7-ad562b10a128","sg_event_id":"Lfnr7qphr2Ipk1Q","sg_message_id":"yP-6vHloRg.filterdrecv-p3iad2-5b5v6r54-19-5EF84758-36.0","timestamp":1593329556,"url":"https:\/\/my_cdn_domain\/template_mail\/header-7D.png)","url_offset":{"index":0,"type":"text"},"useragent":"Mozilla\/5.0 (Windows NT 6.3; Trident\/7.0; rv:11.0) like Gecko"}]

It looks like this user is using an older version of Thunderbird on Windows 8.1 (which is already quite old), maybe the email client is adding something strange to these url's?

I'm gonna close this issue for now since I can not reproduce it, but feel free to open it again as soon as you find some new information that could lead to a fix.