Forum Moderators: DixonJones
In other words, if a user got to my site searching on "Blue Widgets" in Google, I'd like to add this to his account record so I know the source of this visit.
Is this possible for organic and paid search?
Have you got SSI enabled on your html pages? Great (if not read up on it).
1. Create a file called trackster.pl in your CGI bin.
Code for trackster.pl:
#!/usr/bin/perl
$from=$ENV{'HTTP_REFERER'};
if ($from =~ "google")
{
$from =~ s/.*q=//;
$from =~ s/&.*//;
$from =~ s/\+/ /g;
open(FILE,">>./google-people.txt");
print FILE "$ENV{'REMOTE_ADDR'} Searched Google For: $from\n";
close(FILE);
}
exit;
# END CODE
----------
2. CHMOD trackster.pl to 755.
3. create a file called google-people.txt in the same directory as the .pl file - CHMOD it to 777
4. Add this line to your SSI enabled pages: <!--#exec cgi="/cgi-bin/trackster.pl" -->
The file google-people.txt will show you what people searched for on Google. If logged in via SSH/telnet you can look at it in real time with "tail -f google-people.txt"
This is of course just a simple example, but this would work.