how do you detect if your website visitor came from a google search result?
Check the $_SERVER['HTTP_REFERER']
variable which should contain the referring URL. Please note that this is not tamper-proof or fail-safe as the Http-Referer
header can easily been changed or modified by a client.
EDIT:
Just googled for phpinfo
(because chanes were high that I get a phpinfo()
page that shows the $_SERVER['HTTP_REFERER']
variable) to show you how the Http-Referer
will look like:
$_SERVER['HTTP_REFERER'] = "http://www.google.de/search?hl=de&q=phpinfo&btnG=Google-Suche&meta="
As you see, you can also extract the search term used in the google query (or detect if the search was initiated by the Google Chrome address bar)...
PHP-Visitor from google
Use: $_SERVER['HTTP_REFERER']
if(strpos($_SERVER['HTTP_REFERER'], 'google'))
echo 'comes from google';
How to capture if a visitor is from a google adwords click
You're correct--you can read this data from the cookies.
To configure the tracking:
connect your adwords and GA
accounts:in your AdWords account, go to My
Account > Account Preferences, click
the "edit" link next to Tracking
then select the box that says
"Destination URL Auto-tagging".
Click "Save Changes";still from your AdWords account,
click the Analytics tab and choose
Analytics Settings > Profile
Settings > Edit Profile Information;
check "Apply Cost Data", then click
Save Changes
So how can you tell if it's working? And where does GA store the data?
Grab an initial __utm.gif request and look at the Referer. Appended to the URL is a new parameter "gclid." This is the keyword-specific parameter (unique to your account). It's this parameter that distinguishes your visitors as AdWord-originating (i.e., "google(cpc)") from "google(organic)" Here's one i just grabbed and anonymized (scrambled the numbers/letters):
Referer: http://www.adomainname.com/?gclid=CKr61p31yKACFZlg4wodjj3gbA
You'll see this identical string in two other places in the same tracking pixel request:
(i) as the value for the GIF Request Parameter "utmp" which is the page request for the current page, and, most importantly;
(ii) as the value for the GIF Requests Parameter "utmcc"--the container for the cookies. The specific cookie that holds the adwords data is __utmz, which is actually the container for all referral data. Here's an anonymized example i just grabbed more or less at random (i.e., i just did search in Google using a query comprised of obvious Adwords and then clicked one of the paid links in my search results, then just pulled the Request Header):
utmcc=__utma%3D755416178.1576730350.1269876846.1269143846.1269143846.1%3B%2B__utmz%3D219726107.1269143846.1.1.utmgclid%3CKr61p31yKACFZlg4wodjj3gbA%7Cutmccn%3D(not%2520set)%7Cutmcmd%3D(not%2520set)%7Cutmctr%3Dhomes%2520for%2520sale%3B
HTTP/1.1
Is there a way to know if someone has bookmarked your website?
Your best bet is to have a Javascript "Bookmark us" link that bookmarks the site and makes an AJAX call to a backend script to store info about a new bookmark in your db. This won't catch people who bookmark your site directly using their browser, but it will give you some idea about the stickiness of your site.
Javascript: obtain visitor's search keyword from document.referrer referred from google search engine
Since Google's move to secure search (that is, over HTTPS), the keyword is not passed with the HTTP Referrer data anymore. On Google Analytics you will see this organic traffic under the keyword (not provided)
Related Topics
How to Join Three Tables in Codeigniter
Multiple Radio Button Array for PHP Form
Convert PHP Array to JSON Tree
In PHP, How to Generate a Big Pseudo-Random Number
Get Number of Weekdays in a Given Month
Check How Many Times Specific Value in Array PHP
Calling PHP Function from Jquery
Mysqli Join Tables from 2 Different Databases
No Database Selected - PHP & MySQL
Show Hide Custom Woocommerce Checkout Field Based on Selected Payment Method
Php: What Is the Complexity [I.E O(1),O(N)] of the Function 'Count'
Sort Array by Value Alphabetically PHP
Table Name as Parameter Using Pdo/MySQL Prepared Statement
Imagick Not Loading Images, with 'Nodecodedelegateforthisimageformat' Error Message
Create Unique Poll/Vote/Survey in PHP
PHP for ; Foreach Variable Scope