Closed marvin-martian closed 8 years ago
What would be your use-case for such a thing ?
By having such a method we can be selective what needs to be tracked. Tracking everything may not be desirable. My use case is that I was asked to do exactly this for legal reasons. Some organisations have legally binding privacy conditions and they will declare which things they will collect information and which not. To be able to implement this I need to be selective. The particular issue I have is that I am not to track linking to third party websites. I am only allowed to track within the scope of the domain.
Then what about some configuration and/or hook to manage this kind of things ? If it's a legal issue I don't think you want to manually check every single link you ever write. So some kind of automation might be welcome, no ?
If it's a legal issue I don't think you want to manually check every single link you ever write.
The thing is it is not MY legal issue. It is the issue of the people writing the content. I don't want to be the one implementing a blanket solution, I would prefer to put the responsibility of that onto the content writers/owners. Let them decide what should be tracked and what shouldn't.
I think a markup on the link is good for that. Maybe it could be a CSS class name. Then via RTE they could add a "no-track" class to the link.
A hook just means that the functionality does not exists unless it is implemented. It is easier to just parse the link for a keyword so that it is not included.
Something like:
private function injectLinksSpy(Email $email, $isPreview)
{
/* Exchange all http:// links html */
preg_match_all('|<a [^>]*href="(https?://[^"]*)"|Ui', $this->html, $urls);
// No-Track Marker
$notrackMarker = Tools:confParam('no-track');
foreach ($urls[1] as $i => $url) {
if ( stripos($url,'newsletter_view_url') == false && stripos($url,'newsletter_unsubscribe_url') == false ) {
// Check for a no-track marker
if (!empty($notrackMarker) && stripos($url,$notrackMarker) != false) {
continue;
}
$newUrl = $this->getLinkAuthCode($email, $url, $isPreview);
/* Two step replace to be as precise as possible */
$link = str_replace($url, $newUrl, $urls[0][$i]);
$this->html = str_replace($urls[0][$i], $link, $this->html);
}
}
}
Would a CSS class be user-friendly enough for non-IT people ?
Also I don't think the no-track marker need to be configurable.
Well the users manage to select a link type download/external via RTE with no problems, so usability is not an issue. If the keyword is configurable it is possible to change it if it conflicts with pre-existing css.
It is in the current pull-request #71
It would be nice if we could add a attribute to a link in a template that would mark the link to be ignored as a spylink.
i.e
That would give us a finer control over what links should be converted as spylinks.