Click tracking does not work with image map

Solutions for other advanced phplisters

Click tracking does not work with image map

Postby sadiqaufy » 1:37pm, Tue 13 Apr, 2010

Hi,
My phplist version is 2.10.10. I have an issue with click tracking. When I use image map ,only the first link (firs map) of the image is tracked, all other links in the map and the first link coming after the image are not tracked , those are direct links. This bug is already reported in mantis

http://mantis.phplist.com/view.php?id=7797
http://mantis.phplist.com/view.php?id=6611


But I could not find any solution . So please help me.
sadiqaufy
phpLister
 
Posts: 9
Joined: 4:54am, Fri 20 Nov, 2009

Re: Click tracking does not work with image map

Postby sadiqaufy » 12:19pm, Tue 11 May, 2010

Finally I got the solution. I don't know is it the right way or not. Even though it is working fine for me.

1. Open the file ' lists/admin/sendemaillib.php'.
2. Replace the line
preg_match_all('/<a(.*)href=["\'](.*)["\']([^>]*)>(.*)<\/a>/Umis',$htmlmessage,$links);
with
preg_match_all('/href=["\'](.*)["\']/Umis',$htmlmessage,$links);

3.Replace the line
$newlink = sprintf('<a%shref="%s://%s/lt.php?id=%s" %s>%s</a>',$links[1][$i],$GLOBALS["scheme"],$website.$GLOBALS["pageroot"],$masked,$links[3][$i],$links[4][$i]);
with
$newlink = sprintf('href="%s://%s/lt.php?id=%s"',$GLOBALS["scheme"],$website.$GLOBALS["pageroot"],$masked);

That is it....

Please let me know if this code has any issues.
sadiqaufy
phpLister
 
Posts: 9
Joined: 4:54am, Fri 20 Nov, 2009

Re: Click tracking does not work with image map

Postby andreacorelli » 6:45pm, Mon 10 Dec, 2012

I am no coder, but the above solution seems to work. I haven't dared to test it though, in fear of breaking up something else. Any one else has tried this solution? With the single image and imagemap emails getting a very low SPAM score, I think it would be wise to implement it on the production version of phplist anyway.

Thanks,
Andrea
andreacorelli
phpLister
 
Posts: 5
Joined: 7:57pm, Tue 27 Nov, 2012

Re: Click tracking does not work with image map

Postby andreacorelli » 12:06pm, Sat 05 Jan, 2013

I tested the above code on the latest production version 2.10.19. Does not work meaning that it still won't track the image maps links. Anyone can help me fixing this out pretty please?

Thanks,
Andrea
andreacorelli
phpLister
 
Posts: 5
Joined: 7:57pm, Tue 27 Nov, 2012

Re: Click tracking does not work with image map

Postby bsjawle » 2:50pm, Tue 14 May, 2013

I believe this is an old post but because I couldn't find resolution in version mentioned in Mantis against this bug, posting how I solved it yesterday if this might be useful.

Trick is to have capture <a> and <area> separately and then process them combined as one array of arrays.
Some code in order
Replace
Code: Select all
preg_match_all('/<a(.*)href=["\'](.*)["\']([^>]*)>(.*)<\/a>/Umis',$htmlmessage,$links); //Original

with
Code: Select all
 preg_match_all('/<a(\s+.*)href=["\'](.*)["\']([^>]*)>(.*)<\/a>/Umis',$htmlmessage,$links);

Add following code
Code: Select all
preg_match_all('/<a(rea\s+.*)href=["\'](.*)["\'](.*)(\s*)\/>/Umis',$htmlmessage,$links2);
   for($i = 0 ; $i <=4; $i++)
   {
      foreach($links2[$i] as $link)
      {
         array_push($links[$i], $link);
      }
   }

and you have PhpList working for both <a> and <area> patterns.
Hope this helps someone !
bsjawle
phpList newbie
 
Posts: 1
Joined: 2:40pm, Tue 14 May, 2013

Re: Click tracking does not work with image map

Postby derykmarl » 11:46am, Wed 18 Dec, 2013

bsjawle wrote:Hope this helps someone !


It does indeed, thanks for posting!

One small tweak, it has a counter to 4 so it only works with 4 image map links. I replaced
Code: Select all
for($i = 0 ; $i <=4; $i++)
with
Code: Select all
for($i = 0 ; $i < count($links2); $i++)
and now it works great.
derykmarl
phpList newbie
 
Posts: 1
Joined: 11:44am, Wed 18 Dec, 2013


Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 2 guests