php how to know that a click came from googleIs it possible to detect a google ad referral in the headers or URL?How can I prevent SQL injection in PHP?PHP: Delete an element from an arrayHow do I make a redirect in PHP?How do I get PHP errors to display?How do I get a YouTube video thumbnail from the YouTube API?How to get the client IP address in PHPHow Do You Parse and Process HTML/XML in PHP?How do you use bcrypt for hashing passwords in PHP?How to fix “Headers already sent” error in PHPHow does PHP 'foreach' actually work?

Modify casing of marked letters

Lay out the Carpet

Dot above capital letter not centred

Hide Select Output from T-SQL

Do I need a multiple entry visa for a trip UK -> Sweden -> UK?

Go Pregnant or Go Home

What would be the benefits of having both a state and local currencies?

How does residential electricity work?

is this a spam?

Teaching indefinite integrals that require special-casing

Greatest common substring

Is this Spell Mimic feat balanced?

Is there any easy technique written in Bhagavad GITA to control lust?

voltage of sounds of mp3files

Do there exist finite commutative rings with identity that are not Bézout rings?

Products and sum of cubes in Fibonacci

How could Frankenstein get the parts for his _second_ creature?

when is out of tune ok?

Using parameter substitution on a Bash array

Why "be dealt cards" rather than "be dealing cards"?

Why does John Bercow say “unlock” after reading out the results of a vote?

What would happen if the UK refused to take part in EU Parliamentary elections?

How to be diplomatic in refusing to write code that breaches the privacy of our users

Why Were Madagascar and New Zealand Discovered So Late?



php how to know that a click came from google


Is it possible to detect a google ad referral in the headers or URL?How can I prevent SQL injection in PHP?PHP: Delete an element from an arrayHow do I make a redirect in PHP?How do I get PHP errors to display?How do I get a YouTube video thumbnail from the YouTube API?How to get the client IP address in PHPHow Do You Parse and Process HTML/XML in PHP?How do you use bcrypt for hashing passwords in PHP?How to fix “Headers already sent” error in PHPHow does PHP 'foreach' actually work?













0















My adsense ad have a dedicated land page.



I want to show the content only to those who came through that ad.



The page is coded with PHP so I'm using $_SERVER['HTTP_REFERER'].



Two questions here:



  1. Is there a better alternative to $_SERVER['HTTP_REFERER'] ?


  2. To what strings/domains should I compare the referrer's domain (I'll handle extracting it)? I mean, I'm guessing that google has more than one domain they're using for the ads, or not? There's doubleclick.com.... any other domain? How can I check it, besides try/fail?










share|improve this question



















  • 1





    Can't you add a parameter to the link you give to google? i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12

    – Michael Haren
    Oct 1 '10 at 3:16











  • @Michael: Correct, yet this is not what I need. I know that it's possible to fake the $_SERVER['HTTP_REFERER'] parameter but it's definitely not as easy as simply copy/paste the parameterized URL.

    – Poni
    Oct 1 '10 at 3:27











  • Please note that you can't rely 100% on $_SERVER["HTTP_REFERER"], since there are anonymizer programs that nullify it's value

    – Rodrigo
    Oct 1 '10 at 3:32















0















My adsense ad have a dedicated land page.



I want to show the content only to those who came through that ad.



The page is coded with PHP so I'm using $_SERVER['HTTP_REFERER'].



Two questions here:



  1. Is there a better alternative to $_SERVER['HTTP_REFERER'] ?


  2. To what strings/domains should I compare the referrer's domain (I'll handle extracting it)? I mean, I'm guessing that google has more than one domain they're using for the ads, or not? There's doubleclick.com.... any other domain? How can I check it, besides try/fail?










share|improve this question



















  • 1





    Can't you add a parameter to the link you give to google? i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12

    – Michael Haren
    Oct 1 '10 at 3:16











  • @Michael: Correct, yet this is not what I need. I know that it's possible to fake the $_SERVER['HTTP_REFERER'] parameter but it's definitely not as easy as simply copy/paste the parameterized URL.

    – Poni
    Oct 1 '10 at 3:27











  • Please note that you can't rely 100% on $_SERVER["HTTP_REFERER"], since there are anonymizer programs that nullify it's value

    – Rodrigo
    Oct 1 '10 at 3:32













0












0








0








My adsense ad have a dedicated land page.



I want to show the content only to those who came through that ad.



The page is coded with PHP so I'm using $_SERVER['HTTP_REFERER'].



Two questions here:



  1. Is there a better alternative to $_SERVER['HTTP_REFERER'] ?


  2. To what strings/domains should I compare the referrer's domain (I'll handle extracting it)? I mean, I'm guessing that google has more than one domain they're using for the ads, or not? There's doubleclick.com.... any other domain? How can I check it, besides try/fail?










share|improve this question
















My adsense ad have a dedicated land page.



I want to show the content only to those who came through that ad.



The page is coded with PHP so I'm using $_SERVER['HTTP_REFERER'].



Two questions here:



  1. Is there a better alternative to $_SERVER['HTTP_REFERER'] ?


  2. To what strings/domains should I compare the referrer's domain (I'll handle extracting it)? I mean, I'm guessing that google has more than one domain they're using for the ads, or not? There's doubleclick.com.... any other domain? How can I check it, besides try/fail?







php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 1 '10 at 13:32









meagar

181k30276294




181k30276294










asked Oct 1 '10 at 3:14









PoniPoni

5,6952063111




5,6952063111







  • 1





    Can't you add a parameter to the link you give to google? i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12

    – Michael Haren
    Oct 1 '10 at 3:16











  • @Michael: Correct, yet this is not what I need. I know that it's possible to fake the $_SERVER['HTTP_REFERER'] parameter but it's definitely not as easy as simply copy/paste the parameterized URL.

    – Poni
    Oct 1 '10 at 3:27











  • Please note that you can't rely 100% on $_SERVER["HTTP_REFERER"], since there are anonymizer programs that nullify it's value

    – Rodrigo
    Oct 1 '10 at 3:32












  • 1





    Can't you add a parameter to the link you give to google? i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12

    – Michael Haren
    Oct 1 '10 at 3:16











  • @Michael: Correct, yet this is not what I need. I know that it's possible to fake the $_SERVER['HTTP_REFERER'] parameter but it's definitely not as easy as simply copy/paste the parameterized URL.

    – Poni
    Oct 1 '10 at 3:27











  • Please note that you can't rely 100% on $_SERVER["HTTP_REFERER"], since there are anonymizer programs that nullify it's value

    – Rodrigo
    Oct 1 '10 at 3:32







1




1





Can't you add a parameter to the link you give to google? i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12

– Michael Haren
Oct 1 '10 at 3:16





Can't you add a parameter to the link you give to google? i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12

– Michael Haren
Oct 1 '10 at 3:16













@Michael: Correct, yet this is not what I need. I know that it's possible to fake the $_SERVER['HTTP_REFERER'] parameter but it's definitely not as easy as simply copy/paste the parameterized URL.

– Poni
Oct 1 '10 at 3:27





@Michael: Correct, yet this is not what I need. I know that it's possible to fake the $_SERVER['HTTP_REFERER'] parameter but it's definitely not as easy as simply copy/paste the parameterized URL.

– Poni
Oct 1 '10 at 3:27













Please note that you can't rely 100% on $_SERVER["HTTP_REFERER"], since there are anonymizer programs that nullify it's value

– Rodrigo
Oct 1 '10 at 3:32





Please note that you can't rely 100% on $_SERVER["HTTP_REFERER"], since there are anonymizer programs that nullify it's value

– Rodrigo
Oct 1 '10 at 3:32












3 Answers
3






active

oldest

votes


















1














$_SERVER['HTTP_REFERER'] is the canonical way to determine where a click came from generally. There are more reliable (and complicated) methods for clicks within a site you fully control, but that's not much help for clicks from Google. Yes, it can be spoofed, and yes, it can be null, but as long as you're not targeting nuclear weapons based on that data, and you can handle null values gracefully, it should be good enough.



As for domains, you have to consider the international google domains, as well as all the google*.com domains.






share|improve this answer























  • Yup, I guess that if I don't hear anything more precise I'll do a wild-card comparison with "google" and "doubleclick", not sure..

    – Poni
    Oct 1 '10 at 3:47


















1














I suggest adding a parameter on the link you give to Google. i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12.



If you are concerned that curious users will play with this parameter, the fix is simple-- redirect via a server 301 redirect when they hit that URL.



That is, if I request yoursite.com/landing?campaign=12, your server--before serving a page-- should log my visit to campaign 12 and redirect me to the plain url yoursite.com/landing. This has the added advantage that reloads won't increment your campaign hit count.



Yes, users could still mess with the original link if they are clever or curious enough to look at it before they click on it, but I think this is going to be far more effective than sniffing the referer.






share|improve this answer






























    -2














    Rather than trying to work out on your own how to measure your page views, you can consider using an existing system for that, like Google Analytics






    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3836312%2fphp-how-to-know-that-a-click-came-from-google%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      $_SERVER['HTTP_REFERER'] is the canonical way to determine where a click came from generally. There are more reliable (and complicated) methods for clicks within a site you fully control, but that's not much help for clicks from Google. Yes, it can be spoofed, and yes, it can be null, but as long as you're not targeting nuclear weapons based on that data, and you can handle null values gracefully, it should be good enough.



      As for domains, you have to consider the international google domains, as well as all the google*.com domains.






      share|improve this answer























      • Yup, I guess that if I don't hear anything more precise I'll do a wild-card comparison with "google" and "doubleclick", not sure..

        – Poni
        Oct 1 '10 at 3:47















      1














      $_SERVER['HTTP_REFERER'] is the canonical way to determine where a click came from generally. There are more reliable (and complicated) methods for clicks within a site you fully control, but that's not much help for clicks from Google. Yes, it can be spoofed, and yes, it can be null, but as long as you're not targeting nuclear weapons based on that data, and you can handle null values gracefully, it should be good enough.



      As for domains, you have to consider the international google domains, as well as all the google*.com domains.






      share|improve this answer























      • Yup, I guess that if I don't hear anything more precise I'll do a wild-card comparison with "google" and "doubleclick", not sure..

        – Poni
        Oct 1 '10 at 3:47













      1












      1








      1







      $_SERVER['HTTP_REFERER'] is the canonical way to determine where a click came from generally. There are more reliable (and complicated) methods for clicks within a site you fully control, but that's not much help for clicks from Google. Yes, it can be spoofed, and yes, it can be null, but as long as you're not targeting nuclear weapons based on that data, and you can handle null values gracefully, it should be good enough.



      As for domains, you have to consider the international google domains, as well as all the google*.com domains.






      share|improve this answer













      $_SERVER['HTTP_REFERER'] is the canonical way to determine where a click came from generally. There are more reliable (and complicated) methods for clicks within a site you fully control, but that's not much help for clicks from Google. Yes, it can be spoofed, and yes, it can be null, but as long as you're not targeting nuclear weapons based on that data, and you can handle null values gracefully, it should be good enough.



      As for domains, you have to consider the international google domains, as well as all the google*.com domains.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Oct 1 '10 at 3:40









      ChrisChris

      1,21586




      1,21586












      • Yup, I guess that if I don't hear anything more precise I'll do a wild-card comparison with "google" and "doubleclick", not sure..

        – Poni
        Oct 1 '10 at 3:47

















      • Yup, I guess that if I don't hear anything more precise I'll do a wild-card comparison with "google" and "doubleclick", not sure..

        – Poni
        Oct 1 '10 at 3:47
















      Yup, I guess that if I don't hear anything more precise I'll do a wild-card comparison with "google" and "doubleclick", not sure..

      – Poni
      Oct 1 '10 at 3:47





      Yup, I guess that if I don't hear anything more precise I'll do a wild-card comparison with "google" and "doubleclick", not sure..

      – Poni
      Oct 1 '10 at 3:47













      1














      I suggest adding a parameter on the link you give to Google. i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12.



      If you are concerned that curious users will play with this parameter, the fix is simple-- redirect via a server 301 redirect when they hit that URL.



      That is, if I request yoursite.com/landing?campaign=12, your server--before serving a page-- should log my visit to campaign 12 and redirect me to the plain url yoursite.com/landing. This has the added advantage that reloads won't increment your campaign hit count.



      Yes, users could still mess with the original link if they are clever or curious enough to look at it before they click on it, but I think this is going to be far more effective than sniffing the referer.






      share|improve this answer



























        1














        I suggest adding a parameter on the link you give to Google. i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12.



        If you are concerned that curious users will play with this parameter, the fix is simple-- redirect via a server 301 redirect when they hit that URL.



        That is, if I request yoursite.com/landing?campaign=12, your server--before serving a page-- should log my visit to campaign 12 and redirect me to the plain url yoursite.com/landing. This has the added advantage that reloads won't increment your campaign hit count.



        Yes, users could still mess with the original link if they are clever or curious enough to look at it before they click on it, but I think this is going to be far more effective than sniffing the referer.






        share|improve this answer

























          1












          1








          1







          I suggest adding a parameter on the link you give to Google. i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12.



          If you are concerned that curious users will play with this parameter, the fix is simple-- redirect via a server 301 redirect when they hit that URL.



          That is, if I request yoursite.com/landing?campaign=12, your server--before serving a page-- should log my visit to campaign 12 and redirect me to the plain url yoursite.com/landing. This has the added advantage that reloads won't increment your campaign hit count.



          Yes, users could still mess with the original link if they are clever or curious enough to look at it before they click on it, but I think this is going to be far more effective than sniffing the referer.






          share|improve this answer













          I suggest adding a parameter on the link you give to Google. i.e. instead of yoursite.com/landing, do yoursite.com/landing?campaign=12.



          If you are concerned that curious users will play with this parameter, the fix is simple-- redirect via a server 301 redirect when they hit that URL.



          That is, if I request yoursite.com/landing?campaign=12, your server--before serving a page-- should log my visit to campaign 12 and redirect me to the plain url yoursite.com/landing. This has the added advantage that reloads won't increment your campaign hit count.



          Yes, users could still mess with the original link if they are clever or curious enough to look at it before they click on it, but I think this is going to be far more effective than sniffing the referer.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 1 '10 at 13:09









          Michael HarenMichael Haren

          76.5k38147197




          76.5k38147197





















              -2














              Rather than trying to work out on your own how to measure your page views, you can consider using an existing system for that, like Google Analytics






              share|improve this answer



























                -2














                Rather than trying to work out on your own how to measure your page views, you can consider using an existing system for that, like Google Analytics






                share|improve this answer

























                  -2












                  -2








                  -2







                  Rather than trying to work out on your own how to measure your page views, you can consider using an existing system for that, like Google Analytics






                  share|improve this answer













                  Rather than trying to work out on your own how to measure your page views, you can consider using an existing system for that, like Google Analytics







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Oct 1 '10 at 3:16









                  SingleNegationEliminationSingleNegationElimination

                  114k19216262




                  114k19216262



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3836312%2fphp-how-to-know-that-a-click-came-from-google%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                      Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                      Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved