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?
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:
Is there a better alternative to
$_SERVER['HTTP_REFERER']
?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
add a comment |
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:
Is there a better alternative to
$_SERVER['HTTP_REFERER']
?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
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
add a comment |
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:
Is there a better alternative to
$_SERVER['HTTP_REFERER']
?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
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:
Is there a better alternative to
$_SERVER['HTTP_REFERER']
?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
php
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
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
$_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.
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
add a comment |
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
.
add a comment |
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
$_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.
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
add a comment |
$_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.
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
add a comment |
$_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.
$_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.
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
add a comment |
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
add a comment |
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
.
add a comment |
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
.
add a comment |
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
.
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
.
answered Oct 1 '10 at 13:09
Michael HarenMichael Haren
76.5k38147197
76.5k38147197
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Oct 1 '10 at 3:16
SingleNegationEliminationSingleNegationElimination
114k19216262
114k19216262
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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