1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Gmail doesn't request my server for 1x1 pixel tracking newsletter

Discussion in 'Programming' started by HussainMHB, Apr 6, 2015.

  1. #1
    Hello,

    I want to track if the sent email is read or not (i know second time, i can't track because of image proxy server. i need only tracking of first time when the user clicks).
    I'm using this code snippet. But, unfortunately it is not working as expected.
    I tried googling for hours but no improvement.
    Can somebody suggest me?

    $headers = "From: ";
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    $to = "";
    $subject = 'Mail Test - ' ;
    $message = "Hi This is testing <br/> <img src='tracker.php' width='1px' height='1px' /> <br/>after tracking pixel image";

    if(mail($to, $subject, $message, $headers)) {
    echo "sent";
    }else {
    echo "error";
    }

    Thanks,
    Hussain Badusha.
     
    HussainMHB, Apr 6, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Perhaps try to actually include an IMAGE, not a PHP-file...
     
    PoPSiCLe, Apr 6, 2015 IP
  3. HussainMHB

    HussainMHB Member

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #3
    Thanks for the response.
    Then how do i track.
    $message = "Hi This is testing <br/> <img src='filename.png' width='1px' height='1px' /> <br/>after tracking pixel image";

    If i use the above message and send it. How can i know if the email is read or not.
    Really, i don't know how to do that?
    I await for you reply

    Thanks,
    Hussain Badusha.
     
    HussainMHB, Apr 6, 2015 IP
  4. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
  5. HussainMHB

    HussainMHB Member

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #5
    Thanks ThePHPMaster,

    I've checked that link.
    They said "our image-hosting servers get a request for the pixel-sized pic, and we use that request to track opens for each subscriber"
    But in my side, what should i do?
    I put image tag along with tracking file. But gmail won't request to my server (localhost) when i click on the particular email.
    Any help would be greatly appreciated.

    Thanks,
    Hussain Badusha.
     
    HussainMHB, Apr 6, 2015 IP
  6. HussainMHB

    HussainMHB Member

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #6
    Hi.

    Can somebody help me?
    It would be great if you anyone gives me a code snippet that does request from gmail to localhost server.
    I await...

    Thanks,
    Hussain Badusha.
     
    HussainMHB, Apr 12, 2015 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    Uhm... wait. You're trying to get Gmail to access something on localhost? Without having localhost available on the Internet? Are you just stupid, or aren't you grasping how localhost works?
     
    PoPSiCLe, Apr 13, 2015 IP
    malky66 likes this.
  8. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #8
    Use the full URL to "tracker.php", not just the script name. How is Gmail supposed to know the domain it's on? Magic? lol
     
    digitalpoint, Apr 13, 2015 IP
  9. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #9
    As a recap.

    1. Use the full URL to the "image"
    2. Set a handler that allows a particular image filename be executed as a php script so you can use whatever.jpg
    3. Use the correct HTML header and html code if you plan to use the img src code.
    4. Don't be stupid.
     
    NetStar, Apr 13, 2015 IP
  10. HussainMHB

    HussainMHB Member

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #10
    Thanks for all of you help.

    May be i should have clearly posted the code. Let me show you once again with little more in detail.

    $headers = "From: ";
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $to = "";
    $subject = 'Mail Test ' ;
    $message = "Hi This is testing <br/> <img src='localhost/tracker.php' width='1px' height='1px' /> <br/>after tracking pixel image";

    if(mail($to, $subject, $message, $headers)) {
    echo "sent";
    }else {
    echo "error";
    }

    The above code snippet tracks promptly as expected, when user opens the particular mail that i sent.
    And i can also store the required information in my db on my localhost server.
    But, the only problem is that i can't track it on gmail.com and live.com. Other than these two services,
    i can go smoothly in tracking without any single issue (yahoo.com, zoho.com, yandex.com, india.com, swissmail.net and few more).

    Regarding running it one localhost, i also put it my code in online and checked it but no improvement. Still, i can't track information
    from gmail and live.com.

    Thanks,
    Hussain Badusha.
     
    HussainMHB, Apr 13, 2015 IP
  11. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #11
    You aren't listening. Do NOT link to it on localhost. Do NOT link an img src to a .php extension. Even IF Google would allow you....you don't even have the http intact for it to be valid. But that's irrelevant...host the script on thw world wide web. Use a handler so allow a specific.jpg file to execute as a PHP file. Then use the appropiate header and html formating.
     
    NetStar, Apr 13, 2015 IP
  12. HussainMHB

    HussainMHB Member

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #12
    Hi, Thanks for the quick response @NetStar
    Actually, there was "http://" before localhost in code snippet. That's why i can track info.

    Let me give it a try as you are suggesting me to use handler on image.
    First of all, pardon me for too much questions right away coming...
    How can i set handler on image and how to track it?
    Should image name (specific.jpg) be valid or just a name?
    I really don't know how to do that. Do you have any sources that i can learn from?
    or Do you have any sample code?
    Again... Thank you very much for quick reply.

    Hussain Badusha.
     
    HussainMHB, Apr 13, 2015 IP
  13. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #13
    Don't link to localhost period. How many times does someone have to tell you?
     
    NetStar, Apr 14, 2015 IP
    digitalpoint likes this.
  14. HussainMHB

    HussainMHB Member

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #14
    Hi folks,
    I'm grateful to you all... Thank you very much guys...

    Finally, i got it working. I'm really so ashamed that how stupid i've been all over this thread (i was so stubborn keep trying it on localhost).
    Eventually, with the help of setting handler for image and using rewrite rules, it worked like a charm.

    Once again thank you so much and i'm pretty much happy right now...
    Hussain Badusha.
     
    HussainMHB, Apr 14, 2015 IP
    NetStar likes this.