uclicks data via email? Need assistance.

Solutions for other advanced phplisters

uclicks data via email? Need assistance.

Postby jimbo » 7:37pm, Wed 15 Sep, 2010

I would like to receive an email containing the users email when they click a specific url.

For instance:

If someone clicks on msgid=5&linkid=8428 I would like that to trigger an email.

I was looking into the lt.php file and this seems quite do-able.

I saw a hack for the piwik stats that addresses a similar request but, not really adaptable to my needs.

I can write a the part of the function that handles the email sending but, I need to know how to send the request to the function and how to query the db in that function.

eg:
Code: Select all
NEED: How to call the function from lt.php

function notifyme($linkid,$usrid) {
NEED: Query the db and get link clicked url
NEED: Query the db and get email address from user id
send mail routine {
no problem
}
}


This will be useful in performing immediate personal follow ups to people who went all the way to a "buy" or "signup" link but never went any farther.
This also allows me to make a flatfile or mysql that would allow me to organize and or share the data without needing a log in to phplist.

Thanks in advance for any assistance.
jimbo
PL Nut
 
Posts: 15
Joined: 7:12pm, Wed 15 Sep, 2010

Re: uclicks data via email? Need assistance.

Postby duncanc » 1:48pm, Thu 16 Sep, 2010

The $linkdata array contains the destination URL in $linkdata['forward']

To get the user's email address you need to modify the query at line 40 to join on the user table. Something like this but untested :

Code: Select all
$linkdata = Sql_Fetch_array_query(sprintf('select lt.*, u.email from %s lt join %s u on lt.userid = u.id where linkid = %d and userid = %d and messageid = %d',
  $GLOBALS['tables']['linktrack'],$GLOBALS['tables']['user'],$linkid,$userid,$messageid));


then $linkdata['email'] will contain the user's email address.
You can then call your function to send an email.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: uclicks data via email? Need assistance.

Postby jimbo » 8:25pm, Fri 17 Sep, 2010

Thank you. Will that possibly create problems with any other functions of phplist?

Does the var have to be $linkdata['email'] or can I add another like $clickdata['email'] and leave the $linkdata['email'] in tact?

Thank you for your assistance.
jimbo
PL Nut
 
Posts: 15
Joined: 7:12pm, Wed 15 Sep, 2010

Re: uclicks data via email? Need assistance.

Postby duncanc » 11:15am, Sat 18 Sep, 2010

jimbo wrote:Thank you. Will that possibly create problems with any other functions of phplist?

If you intend to only read the fields then there should not be any effect on other functions of phplist. The file lt.php is fairly self-contained so you should be able to see where the variables are used.
jimbo wrote:Does the var have to be $linkdata['email'] or can I add another like $clickdata['email'] and leave the $linkdata['email'] in tact?

You can add another field but if you are only reading the fields then there is no need to.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: uclicks data via email? Need assistance.

Postby jimbo » 3:56pm, Sat 18 Sep, 2010

Thank you again. Could you provide more detail on your example?

Break it down for me so I can learn instead of just trying it?

Also, would I send it to the custom email function right after that or at the end of the routine before the header line?

Thanks so much for your patience with me here.
jimbo
PL Nut
 
Posts: 15
Joined: 7:12pm, Wed 15 Sep, 2010

Re: uclicks data via email? Need assistance.

Postby duncanc » 5:06pm, Sat 18 Sep, 2010

Not sure what more you need to know.
Change the query to my earlier example, then call your function to send the email, passing as parameters the user email address and the destination URL.
You can place the call anywhere before the exit statement.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: uclicks data via email? Need assistance.

Postby jimbo » 7:13pm, Sat 18 Sep, 2010

Just wanted the mysql explained.

I will replace ~line 40 statement with your statement.

Here is what I will try at the end:

Code: Select all
$to = "name@somedomain.org";
$subject = "Stats";
$body = $linkdata['forward'];
$headers = "From: someone@somewhere.org\r\n" . "X-Mailer: php";
mail($to, $subject, $body, $headers);
##
header("Location: " . $linkdata['forward']);
exit;
?>


Does that look in order?

This is on a live install so, even though I backed up everything, I don't want to restore if i don't need to.

Thanks again, your guidance is greatly appreciated.
jimbo
PL Nut
 
Posts: 15
Joined: 7:12pm, Wed 15 Sep, 2010

Re: uclicks data via email? Need assistance.

Postby duncanc » 9:15pm, Sat 18 Sep, 2010

Yes that looks OK, but you are not using the email address of the subscriber. Should that go in the body of the email?

Bear in mind that all of this information is already in the statistics and can be viewed through phplist.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: uclicks data via email? Need assistance.

Postby jimbo » 9:40pm, Sat 18 Sep, 2010

Thanks,

See, I am pretty clueless. :?

The more I look at this, the more it looks like array elements, right?

So....
Code: Select all
$body = "Email:" .$linkdata['email'] ."\n Link ID:" . $linkdata['$linkid'].
"\n UserID:". $linkdata['$userid']. "\n Message ID:". $linkdata['$messageid'];


If so, WE HAVE COMPREHENSION!
jimbo
PL Nut
 
Posts: 15
Joined: 7:12pm, Wed 15 Sep, 2010


Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest