Hi
On my Site How can I tell if someone has clicked on a link that leads to a outside URL?
Thank you..
I don't think you can. Maybe it's possible by using javascript in some way.
What do you need to know that for?
I am studying advertising
On my site I have links to outside sites.
If I can record the click thrus from my site I may be able to gauge advertising revenue. Just like Google does.
Thank you
Can't you use google analytics for that? If you are using google analytics take a look at "Top Exit Pages". "Site Overlay" might also be useful.
You are most likely correct. But they use methods that I would like to know about..
Maybe you can use php redirecting. All your links will go on same php page (script). From there with switch you can write counting (and other) data in MySql or Flat File and then redirect to the right external page. I think this is the simplest way for your needs.
Sonam
if you can control the link submission/advertisement then u can count the clicks.
I dont know what kind of advertising system you are talking about. If you have a system like Adsense, then you can count the clicks by saving all the links into a table in database and assign an ID to each link. Then create your site links like
| Code: |
| http://www.your-example-site.com/ad.php?id=123456 |
the script ad.php could record the click and then forward the user to the address already saved to database against the ID 12345.
GOt it?
If I were you, I'd use a simple PHP script to do that.
When you made a link, the HREF part of it would look something like this:
| Code: |
| http://example.com/redirect.php?url=http://someurl.net |
The Script for redirect.php would do something to record the click (like submit it to a database) and it would use what is contained in ?url= to forward the person to that page.
-Nick

A very simple way would be to use Google Analytics. They have a scriptlet which uses onclick() to call an event.
The event is your outbound click.
Yes just use Google Analytics or some pre-made software for analysis. It is possible to DIY but software already exists for it
I think u can use same php code.

u can keep track of
mean count nimber of clicks whan a link
just php code
simply whaen abc.com cliks a count is increamentes by one
thats all
You can use PHP and a MySQL database to track how someone clicked an ad.
Instead of the link going to the page itself, have it go to a page where it ads 1 to the number of times it's been clicked. Then redirect to the page advertised.
Like this:
heres ad.html:
| Code: |
<a href='ad1.php'>Ad1</a><br>
|
and heres ad1.php
| Code: |
<?
$sql = mysql_query("SELECT * FROM `ads` WHERE `adname` = 'ad1'");
$sql = mysql_fetch_assoc($sql);
$count = $sql['adcount']+1;
mysql_query("UPDATE `ads` SET `adcount` = '$count' WHERE `adname` = 'ad1'");
?>
<script language='javascript'>
window.location = 'the_ad.html';
</script>
|
Your could try that...
Here's a better way to do what Damascus_Steel's code does
| Code: |
<a href='ad.php?id=1'>Ad1</a><br>
|
| Code: |
<?php
... connect to database ...
if(isset($_GET['id'])){
mysql_query('UPDATE ads SET ad_count=ad_count+1 WHERE ad_id=' . $_GET['id']);
if(mysql_affected_rows() > 0){
$res = mysql_query('SELECT * from ads WHERE ad_id=' . $_GET['id'] . ' LIMIT 0,1');
$rec = mysql_fetch_array($res, MYSQL_ASSOC);
header('Location: ' . $rec['ad_url']);
}
}
header('Location: /index.php');
?>
|