Hi,

This might be a simple question, but I have an affiliate site that I want to drive traffic to, and the traffic will be coming from various sources.

All I want to know is that I got the traffic count that is being contracted for from each source...

My first thought is to create a sub-domain for each traffic source and utilize a DB update query to increment the visitors on the index page for that sub-domain, and then Automatically redirect the visitor to the actual affiliate page.

This would accomplish 2 things -

  1. give me a count on each sub-domain to compare to the contract
  2. make the link easier without the affiliate code at the end of it.

I guess the basic question is whether there is an easier quicker way to do this other then creating a mysql table to keep track of the visitor count per sub-domain?

Suggestions are welcome.
Thanks
Douglas

Recommended Answers

All 5 Replies

I guess this must not have been a very good question or at least one that anyone wanted to answer...

Guess that means using a database...

So sorry for not seeing this question until now. This can be managed yourself, through a database. However, you don't need a subdomain for each traffic source. You can easily pass in a UTM parameter for each traffic source, which has the added benefit of being recognized and stored in Google Analytics.

Another option is to use many of the affiliate suites that exist to manage this, but of course that would mean sharing commission.

I guess the basic question is whether there is an easier quicker way to do this other then creating a mysql table to keep track of the visitor count per sub-domain?

It depends on what you need to track. If you just want to track traffic count, then simply use ?utm_ variables and track them with Google Analytics. They'll also track conversions for you.

If you actually need to split commissions, etc. you need to set up a database to manage this, or use a third-party affiliate suite.

Hi Dani,

Thanks for being the one with the answers for me it seems, all the time.

Baiscally what I'm doing is this...

I'm an affiliate of a program and they provide a FREE promo site with a short 4 minute video overview and then links to register a free account that are linked to my affiliate account...

I'm paying for advertising from multiple sources and all pointing to that page.

I have no control on that page, so can't make any determinations as to which source the traffic is coming from.

My Solution was to create a Sub domain for each traffic source and simply redirect visitors to the promo page in the index page of that sub domain.

What I would like to be able to do is simply know the number of times that sub-domain has redirected someone through...
But, if I could get any additiional information i.e. IP / country / etc... that would be even better.

So, that is where I'm at. If there is a better way then to record visits in a DB table, please let me know...

Thanks again,
Douglas

Hey Dani,
Just thought I would let you know what I ended up doing to resolve this question...
Decided that using a database would make the most sense for future expansion.

I did end up creating a sub domain for each traffic provider because there are only a few to deal with
The sub-domain index page:

<?php //  Simple counter at the moment
  include "../connect.php";  // connects to database
  $provider = "jude"; // username for advertiser providing the traffic
  $visitor_ip = getUserIpAddr();  // IP address of the visitor to the site
  $visit_date = HereNow() ;
  $sql_insert = "
    INSERT INTO counter (id, provider, visitor_ip, visit_date)
    VALUES ('', '".$provider."', '".$visitor_ip."', '".$visit_date."')
  ";
  $sql = mysqli_query($connection,$sql_insert);
  header("Location: https://sharebeurax.com/?id=089098480276445");
  exit;

  //**********************************************
  // Function to retrieve the visitors IP Address
  // simple call  $var = getUserIpAddr();
  function getUserIpAddr(){
    if(!empty($_SERVER['HTTP_CLIENT_IP'])){
      //ip from share internet
      $ip = $_SERVER['HTTP_CLIENT_IP'];
    }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
      //ip pass from proxy
      $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }else{
      $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
  }
  // ***********************************************************************
  // generate Y-m-d format for mySql based on specified timezone
  function HereNow(){
    date_default_timezone_set('America/Chicago');
    $new_date = date("Y-m-d H:i:s");
    return $new_date;
  }
?>

The DB table generated by visitors to the site by way of the sub-domains

CREATE TABLE `counter` (
  `id` int(15) NOT NULL,
  `provider` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Username of Provider',
  `visitor_ip` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'IP address of visitor',
  `visit_date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `counter`
  ADD PRIMARY KEY (`id`);

To view the results, I have a simple query and display script

<?php //  View Results from counter at the moment
  include "connect.php";  // connects to database

  $sql_data = "
  SELECT provider, count(distinct visitor_ip) as total_ips, count(id) as visitors
  FROM counter
  GROUP BY provider
  ";

echo "Distinct IP addresses VS visitors<br><br>";

  $sql = mysqli_query($connection,$sql_data);
  WHILE ($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)) {
    echo "provider : ".$row['provider']." || total_ips : ".$row['total_ips']." || visitors : ".$row['visitors']."<br><br>";
  }

?>

Which gives a very basic display of the info

Distinct IP addresses VS visitors

provider : jude || total_ips : 60 || visitors : 65

provider : Read || total_ips : 80 || visitors : 167

This is all very basic, but leaves a lot of room for improvement and expansion, while telling me what I need to know at the moment.

Thanks again for your help.
Douglas

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.