Forum Moderators: open

Message Too Old, No Replies

Passing Data

Passing referrer to a script on another site

         

rickylr

4:58 pm on Feb 13, 2006 (gmt 0)

10+ Year Member



First, what I'm trying to accomplish. I have a few websites, some under my control (i.e., I have the registered, control the content) and some under partial control (i.e., blog at a blogsite) where I can modify the template. Think of these two types of sites as A and B.

At both A & B, I've put in a CSS reference to a php file on another site I control (we'll call it site C), using the Link Rel=stylesheet, then an HREF to the php script on site C, though instead of a CSS file it's a php file. The php runs on site C and records time of visit, IP address, etc., but for the referrer it (of course) records the site that called the script (either A or B). While I'd like to keep that info, I'd also like to record the referrer that led the surfer to site A or B. In other words, I want to pass the data from the original site, A or B, to site C for logging.

Basically, I'm looking for something like the functions you get with sitemeter.com, but don't want to use something like sitemeter. Since sitemeter and others do this sort of thing I know it's doable, but I've not figured out how to accomplish the task and after off and on trying various ways and off and on searching for ways, I'm still not figuring it out or finding it. Any suggestions?

Thanks,

Rick

DrDoc

5:00 pm on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld! [WebmasterWorld.com]

Would it be alright to just pass the original referrer as an argument in the querystring?

rickylr

5:10 pm on Feb 13, 2006 (gmt 0)

10+ Year Member



>Would it be alright to just pass the
>original referrer as an argument
>in the querystring?

It'd be alright with me, but mechanically how do I go about that. Also, keep in mind I'm limited in what I can do at the blog site.

One note I should have added: I'm by no means a guru -- nor even accomplished -- with php nor java; I don't program in them as a hobby nor as my livelihood. I only dig into them a bit when I want to accomplish something, so have played around with both. I do have some programming in my background, but it's older knowledge (as befits an older person - smile).

Thanks,

Rick

rickylr

5:52 pm on Feb 13, 2006 (gmt 0)

10+ Year Member



Another thing to keep in mind is that I don't want to redirect the person to the other website, I just want to get some information to a php script on the other website. So a redirect while setting the querystring wouldn't work, as I don't want the user to be redirected. Or, at least I don't see how it would work.

Rick

DrDoc

6:12 pm on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JavaScript solution:

<script type="text/javascript">
document.write('<link rel="stylesheet" src="http://www.example.com/main.css?referrer=' + document.referrer + '">');
</script>
<noscript>
<link rel="stylesheet" src="http://www.example.com/main.css">
</noscript>

PHP Solution:

<link rel="stylesheet" src="http://www.example.com/main.css?referer=<?=$_SERVER["HTTP_REFERER"]?>">

JollyK

6:34 pm on Feb 13, 2006 (gmt 0)

10+ Year Member



SSI solution (I think):

<link rel="stylesheet" src="http://www.example.com/main.css?referer=<!--#echo var="HTTP_REFERER" -->">

DrDoc

6:35 pm on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That looks right, JollyK :)

rickylr

7:39 pm on Feb 13, 2006 (gmt 0)

10+ Year Member



Made changes as follows:
<script type="text/javascript">
document.write('<link rel="stylesheet" src="http://www.example.com/main.php?referrer=' + document.referrer + '">');
</script>
<noscript>
<link rel="stylesheet" src="http://www.example.com/main.php">
</noscript>

i.e., changed the .css to .php (wasn't sure how I'd trigger the php file to run by using the .css extension).

That didn't work; for whatever reason, neither site would access the script (at least, from the script side of things it no longer "triggered"). So then changed it to mimic the original call I was using:

link rel="stylesheet" type="text/css" href=

instead of

link rel="stylesheet" src=

and that now works. I get what I'm looking for with the PHP REQUEST_URI variable, and it also shows up in the PHP REMOTE_QUERY variable.

Thanks, guys.

Rick

rickylr

7:41 pm on Feb 13, 2006 (gmt 0)

10+ Year Member



Make that the QUERY_STRING variable.

Rick

DrDoc

8:23 pm on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I apologize for leaving out the type attribute in my example.

rickylr

8:38 pm on Feb 13, 2006 (gmt 0)

10+ Year Member



> Yes, I apologize for leaving out
>the type attribute in my example.

No reason to apologize; I only mentioned my changes so someone could correct me if I'd done something stupid in making the changes. Your help me a ton of time.

Thanks again.

Rick

rickylr

8:45 pm on Feb 13, 2006 (gmt 0)

10+ Year Member



Freakin' computers: do what I want, not what I tell you to do.

Should have been "Your help *saved* me a ton of time" as opposed to "Your help me a ton of time."

Rick

DrDoc

8:45 pm on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



;)

Bernard Marx

11:59 pm on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So you haven't gone metric yet then, rickylr?