Jump to content

link click tracking???


forcer

Recommended Posts

I have a list of links in an array, and a small script that will show a link from the array at random.

 

is there anything i can add to it that will record the number of times each link is clicked. maybe just stored in a text file or something?

 

here is the source if it helps:

 

<?php

$links = array('<a href="link1">link1</a>', '<a href="link2">link2</a>','<a href="link3">link3</a>','<a href="link4">link4</a>'); 

$items = $links;

$item = rand(0, sizeof($items)-1);

echo $items[$item];

?>


Link to comment
https://forums.phpfreaks.com/topic/131630-link-click-tracking/
Share on other sites

As revraz stated, a text file or database would be the best solution. I'd recommend the database as you're almost sure to have another use for one. In the meantime, I cleaned up your code which I think is easier to maintain:

 

<?php
$links = array('link1', 'link2', 'link3', 'link4'); 

$items = $links;

$item = rand(0, sizeof($items)-1);

$link = $items[$item];

echo '<a href="' . $link . '">' . $link . '</a>';
?>

Link to comment
https://forums.phpfreaks.com/topic/131630-link-click-tracking/#findComment-683661
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.