Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add tracking to internal anchor URLs #20115

Merged

Conversation

larssandergreen
Copy link
Contributor

Before

Tracking is added to internal anchor links, breaking them.

After

Internal anchor links do not have tracking added and so they work in emails (where the email client supports them).

Tested and works in both traditional and Mosaico mailings. Based on @totten's suggestion here.

@civibot
Copy link

civibot bot commented Apr 21, 2021

(Standard links)

@civibot civibot bot added the master label Apr 21, 2021
@totten
Copy link
Member

totten commented Apr 21, 2021

@sluc23 @mattwire Any chance you could give this a whirl?

@larssandergreen
Copy link
Contributor Author

For purposes of streamlining testing, I could put this related proposed change in here too.

if (preg_match('/\.(png|jpg|jpeg|gif|css)[\'"]?$/i', $url)
or substr_count($url, 'civicrm/extern/')
or substr_count($url, 'civicrm/mailing/')
or ($url[0] === '#')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@larssandergreen would be worth it to add here another condition as ?:
or substr_count($url, 'mailto:')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good reason not to track mailto: links? I'm in favour of keeping them in the clickthrough report, both in terms of counting them as a click for the overall rate and in the individual link statistics.
I guess for people who use a non-browser based client, there's a roundtrip to the browser and back for the clicked link, but is that a big problem?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm ok, we don't see the value of that tracking those, specially when sending and email through a SMTP provider that tracks its own stats, so it's a triple jump to get at the end to compose an email. But seems fair to follow the discussion in a different issue/PR, than this one focused on local anchors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, it looks like there was a previous endeavor track mailto:s when use BAO delivery -- eg @JKingsnorth's #7950.

I guess when considering whether to track a URL, there will be a few buckets like:

  • Cases where everyone agrees tracking is appropriate. (Outbound http(s) URLs)
  • Cases where everyone agrees tracking is not appropriate. (Page-internal anchors)
  • Cases where people may reasonably have different opinions (eg mailto:).

I'd be a soft +1 for some kind of setting or hook to address the latter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to @totten 's +1 to a setting or hook to address mailto: (or even whatsapp: etc.) =]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good to me too. We should cover at least mailto: and tel:, I'd think. But that's another PR.

@larssandergreen
Copy link
Contributor Author

larssandergreen commented Apr 23, 2021

I've also added a similar PR to only track <a> URLs, instead of all URLs inside a tag (as above).

@eileenmcnaughton
Copy link
Contributor

@sluc23 @JKingsnorth @totten - I've read through the discussion on this PR and my take is that people think the change in this PR should be merged but there is an extension that is not in it and not agreed. On that basis I'm giving the PR 'merge-ready' - please speak now if for any reason you do not think this code and our codebase shall be wed together from this day forth until a PR do them part

@eileenmcnaughton eileenmcnaughton added the merge ready PR will be merged after a few days if there are no objections label Aug 6, 2021
@mattwire
Copy link
Contributor

Merging based on tag

@mattwire mattwire merged commit f01582a into civicrm:master Aug 29, 2021
@larssandergreen larssandergreen deleted the fix-internal-anchor-URLs-in-mailings branch November 5, 2022 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants