Results 1 to 14 of 14
  1. #1
    WBM's Avatar
    WBM
    WBM is offline Public Member
    Join Date
    May 2017
    Posts
    410
    Thanks
    39
    Thanked 97 Times in 70 Posts

    Cool Tracking & Redirect Script

    Hey Folks


    OK so here is all the code you guys need for a click tracking & redirect script


    First of all if you want to capture the visitors country code you need to create a FREE account at IP Stack
    https://ipstack.com/signup/free


    Once done you then can login and you will see your API key ( KEEP THIS PRIVATE ! )


    Create a file called play.php and paste the code below and then edit
    Code:
    <?php
    
    
    // Display Message In Case Script Takes A While To Finish
    	echo 'Redirecting .... Please Wait';
    //
    
    
    // Database Info
    	$dbn = 'DATABASE-NAME';
    	$dbu = 'USERNAME';
    	$dbp = 'PASSWORD';
    	$dbh = 'localhost';
    	$dbc = mysqli_connect($dbh,$dbu,$dbp,$dbn);
    //
    
    
    // Info To Be Added
    	$site = 'PlayMegaMoolah.co.uk'; // Site Name To Be Tracked
    	$brand = $_GET['brand']; // Desired Destination
    	$dd = date('d');
    	$mm = date('m');
    	$yy = date('Y');
    	$ip = $_SERVER['REMOTE_ADDR'];
    //
    
    
    // Initialize CURL:
    	$access_key = 'YOUR API KEY';
    	$ch = curl_init('http://api.ipstack.com/'.$ip.'?access_key='.$access_key.'');
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    	$json = curl_exec($ch);
    	curl_close($ch);
    	$api_result = json_decode($json, true);
    	$ccode =  $api_result['country_code'];
    	$cname =  $api_result['country_name'];
    //
    
    
    // Add Visit Info Into DB
    	$addstat = mysqli_query($dbc,"INSERT INTO `tracking` (day,month,year,ip,cc,cname,site,destination) VALUES ('$dd','$mm','$yy','$ip','$ccode','$cname','$site','$brand')");
    //
    
    
    
    
    	// I HAVE LEFT MY BRAND NAMES AND LINKS IN BELOW SO YOU CAN SEE HOW THIS FLOWS FROM THE HTACCESS
    // FILE TO HERE - REMEMBER TO CHANGE BRANDS THERE AND IN HERE !
    if($addstat) 
    	{
    		if($brand == '') // If brand is empty it will redirect to this
    		{
    			$header = 'https://ads.affiliatecruise.com/redirect.aspx?pid=xxxxx&bid=xxxx';
    			} elseif($brand == 'genesis-slots') 
    		{
    			$header = 'https://ads.affiliatecruise.com/redirect.aspx?pid=xxx&bid=xxx';
    		} elseif($brand == 'slots-baby') {
    			$header = 'https://affiliates.slotsbaby.com/Redirect.aspx?mid=xxx';
    		} elseif($brand == 'wizard-slots') {
    			$header = 'https://affiliates.wizardslots.com/Redirect.aspx?mid=xxx';
    		} elseif($brand == 'thor-slots') {
    			$header = 'https://affiliates.thorslots.com/Redirect.aspx?mid=xxx';
    		} elseif($brand == 'easy-slots') {
    			$header = 'https://affiliates.easyslots.com/Redirect.aspx?mid=xxx';
    		} elseif($brand == 'cozino') {
    			$header = 'http://affiliates.cozino.com/Redirect.aspx?mid=xxx';
    		} elseif($brand == 'yukon-gold') {
    			$header = 'https://iredirect.net/referral/?site=yg&aff_id=xxxx';
    		}
    	  header("Location:$header");
    	}
    //
    ?>





    Now for the Database Table - Launch PHPMYADMIN
    Create a New Database Then click SQL and paste this code to create the table ( remember to add the details to the code above )
    Code:
    - phpMyAdmin SQL Dump
    -- version 4.8.3
    -- https://www.phpmyadmin.net/
    --
    -- Host: localhost:3306
    -- Generation Time: Mar 20, 2019 at 10:23 AM
    -- Server version: 10.0.38-MariaDB-cll-lve
    -- PHP Version: 7.2.7
    
    
    SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
    SET AUTOCOMMIT = 0;
    START TRANSACTION;
    SET time_zone = "+00:00";
    
    
    
    
    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8mb4 */;
    
    
    --
    -- Database: `winspins_tracking`
    --
    
    
    -- --------------------------------------------------------
    
    
    --
    -- Table structure for table `tracking`
    --
    
    
    CREATE TABLE `tracking` (
      `vid` bigint(8) NOT NULL,
      `day` text NOT NULL,
      `month` text NOT NULL,
      `year` text NOT NULL,
      `ip` text NOT NULL,
      `cc` text NOT NULL,
      `cname` text NOT NULL,
      `site` text NOT NULL,
      `destination` text NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    
    --
    -- Indexes for dumped tables
    --
    
    
    --
    -- Indexes for table `tracking`
    --
    ALTER TABLE `tracking`
      ADD PRIMARY KEY (`vid`);
    
    
    --
    -- AUTO_INCREMENT for dumped tables
    --
    
    
    --
    -- AUTO_INCREMENT for table `tracking`
    --
    ALTER TABLE `tracking`
      MODIFY `vid` bigint(8) NOT NULL AUTO_INCREMENT;
    COMMIT;
    
    
    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

    Here is the .htaccess File
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^egccc\.pgvrgeskmgsuurgn\.co.uk$ [NC]
    RewriteRule ^(.*)$ https://www.playmegamoolah.co.uk/$1 [L,R=301]
    
    
    RewriteRule ^play$ play.php?brand=
    RewriteRule ^sloty$ play.php?brand=sloty
    RewriteRule ^play/slots-baby$ play.php?brand=slots-baby
    RewriteRule ^play/wizard-slots$ play.php?brand=wizard-slots
    RewriteRule ^play/thor-slots$ play.php?brand=thor-slots
    RewriteRule ^play/easy-slots$ play.php?brand=easy-slots
    RewriteRule ^play/cozino$ play.php?brand=cozino
    RewriteRule ^play/yukon-gold$ play.php?brand=yukon-gold
    RewriteRule ^play/genesis-slots$ play.php?brand=genesis-slots

    Then in your pages simply link like play/BrandName


    Enjoy !

  2. The Following 2 Users Say Thank You to WBM For This Useful Post:

    DanHorvat (20 March 2019), PromoteCasino (20 March 2019)

  3. #2
    WBM's Avatar
    WBM
    WBM is offline Public Member
    Join Date
    May 2017
    Posts
    410
    Thanks
    39
    Thanked 97 Times in 70 Posts

    Default

    oh the above also forces non-HTTPS pages to HTTPS so if you you dont want it to do that remove this from the .htaccess file
    Code:
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^agmmqsooo\.lgpmbshdsqewyseggdsz\.co.uk$ [NC]
    RewriteRule ^(.*)$ https://www.playmegamoolah.co.uk/$1 [L,R=301]
    Oh and remember to remove the reference to playmegamoolah.co.uk obviously

  4. #3
    WBM's Avatar
    WBM
    WBM is offline Public Member
    Join Date
    May 2017
    Posts
    410
    Thanks
    39
    Thanked 97 Times in 70 Posts

    Default

    If you want the data stored in a CSV file instead let me know and I'll just create a slightly modified version of the above script

    Hope someone finds this useful

  5. #4
    DanHorvat's Avatar
    DanHorvat is offline Private Member
    Join Date
    November 2008
    Location
    Actual location may vary.
    Posts
    1,994
    Blog Entries
    3
    Thanks
    1,417
    Thanked 1,319 Times in 783 Posts

    Default

    Cool, I had something like this before.

    Tracking bots is the real problem - does your script track bot visits or only actual clicks?
    Professional bizdev can help you, the affiliate, to negotiate better terms with casinos. PM for details and a free evaluation of what I can do for you. All geos.

  6. #5
    WBM's Avatar
    WBM
    WBM is offline Public Member
    Join Date
    May 2017
    Posts
    410
    Thanks
    39
    Thanked 97 Times in 70 Posts

    Default

    It tracks clicks however if you can find a list of all known bot IP's it can easily be integrated to not track them
    Could also modify the script to not track a click to the same link from the same IP within x amount of seconds etc anything is possible to add-on

  7. #6
    TheGooner's Avatar
    TheGooner is offline Private Member
    Join Date
    March 2007
    Location
    New Zealand
    Posts
    4,563
    Thanks
    2,092
    Thanked 4,533 Times in 2,175 Posts

    Default

    Quote Originally Posted by DanHorvat View Post
    Tracking bots is the real problem - does your script track bot visits or only actual clicks?
    I prefer to track everything.
    My reporting lets me choose whether to display bot traffic or not.

    Sometimes I only want to know about real humans ...
    Sometimes I want the latest bots so I can ban user strings or ip addresses.
    Sometimes I have to examine the click history to find a bot through clik patterns, locate the server farm and ban it.

  8. #7
    TheGooner's Avatar
    TheGooner is offline Private Member
    Join Date
    March 2007
    Location
    New Zealand
    Posts
    4,563
    Thanks
    2,092
    Thanked 4,533 Times in 2,175 Posts

    Default

    Quote Originally Posted by WBM View Post
    It tracks clicks however if you can find a list of all known bot IP's it can easily be integrated to not track them
    Many millions of ips.

  9. #8
    allfreechips's Avatar
    allfreechips is offline Private Member
    Join Date
    August 2010
    Location
    Ohio - The taxing state
    Posts
    1,627
    Thanks
    220
    Thanked 829 Times in 523 Posts

    Default

    I use tracking of speed vs re-clicks with IP's to determine bots ext. also use a db for your links not a list in htaccess.. theres a bunch of methods out there im sure. also I would use prepared statements
    AFC MEDIA LLC COMPLETE GAMING AFFILIATE SOLUTION
    Statsfetch.com
    secure / powerful inexpensive stats fetch system - Free for 20 provers always
    Allmediamatter
    Interface for casino owners/managers to add their affiliates and brands to feed ezcasinoaff
    Allfreechips -
    My 24 year old SEO casino site

  10. #9
    WBM's Avatar
    WBM
    WBM is offline Public Member
    Join Date
    May 2017
    Posts
    410
    Thanks
    39
    Thanked 97 Times in 70 Posts

    Default

    Got a crawler & bot IP list so will implement a checking script to the above tomorrow so will specify whevether visitor was a bot of actual visitor

    Would anyone prefer a CSV file instead of database data ?

  11. #10
    WBM's Avatar
    WBM
    WBM is offline Public Member
    Join Date
    May 2017
    Posts
    410
    Thanks
    39
    Thanked 97 Times in 70 Posts

    Default

    Quote Originally Posted by TheGooner View Post
    Many millions of ips.
    1'740'240 crawler and bad bot ips so far list & updates is free so will integrate this into script

  12. #11
    WBM's Avatar
    WBM
    WBM is offline Public Member
    Join Date
    May 2017
    Posts
    410
    Thanks
    39
    Thanked 97 Times in 70 Posts

    Default

    Quote Originally Posted by TheGooner View Post
    I prefer to track everything.
    My reporting lets me choose whether to display bot traffic or not.

    Sometimes I only want to know about real humans ...
    Sometimes I want the latest bots so I can ban user strings or ip addresses.
    Sometimes I have to examine the click history to find a bot through clik patterns, locate the server farm and ban it.
    I used to redirect bots onto themselves lol

  13. The Following User Says Thank You to WBM For This Useful Post:

    TheGooner (20 March 2019)

  14. #12
    Muppet is offline Private Member
    Join Date
    December 2007
    Posts
    577
    Thanks
    166
    Thanked 661 Times in 290 Posts

    Default

    It's a decent simple example, so cheers for sharing with people here.

    I agree with the comment that storing affiliate links in .htaccess is not a great idea because:
    - It's going to quickly get out of hand if you have more than a handful of sites;
    - You're setting up a situation where non-coders may have to regularly update code; and
    - A syntax error in .htaccess due to a mistake when updating a link could bring your site down.

    Another problem I see is that you have made your click logging process dependent on an outside third party's server. That curl request you are doing is synchronous so if I as a visitor click a link on your site I have to wait until the request is made from your server and returned from theirs. If their server is slow or down, or they go out of business, I might have to wait a long time and give up on the click and close my window.

    And the only reason you are doing it is to get the country code for an IP address, which is not something the visitor should have to wait for as they will never see it anyway. If you really need it you should be getting that info via a local database like Maxmind Geoip, or accessing the third party via an offline process during a cron run or similar using the IP address you recorded in the database.

  15. #13
    WBM's Avatar
    WBM
    WBM is offline Public Member
    Join Date
    May 2017
    Posts
    410
    Thanks
    39
    Thanked 97 Times in 70 Posts

    Default

    Quote Originally Posted by Muppet View Post
    It's a decent simple example, so cheers for sharing with people here.

    I agree with the comment that storing affiliate links in .htaccess is not a great idea because:
    - It's going to quickly get out of hand if you have more than a handful of sites;
    - You're setting up a situation where non-coders may have to regularly update code; and
    - A syntax error in .htaccess due to a mistake when updating a link could bring your site down.

    Another problem I see is that you have made your click logging process dependent on an outside third party's server. That curl request you are doing is synchronous so if I as a visitor click a link on your site I have to wait until the request is made from your server and returned from theirs. If their server is slow or down, or they go out of business, I might have to wait a long time and give up on the click and close my window.

    And the only reason you are doing it is to get the country code for an IP address, which is not something the visitor should have to wait for as they will never see it anyway. If you really need it you should be getting that info via a local database like Maxmind Geoip, or accessing the third party via an offline process during a cron run or similar using the IP address you recorded in the database.
    I see what your saying .. head over to dreamcarcomp.co.uk and try it there is no delay whatsoever
    true could update seperately never thought about that

  16. #14
    WBM's Avatar
    WBM
    WBM is offline Public Member
    Join Date
    May 2017
    Posts
    410
    Thanks
    39
    Thanked 97 Times in 70 Posts

    Default

    also the curl request is closed at that point where it stores the data and it will still execute even if curl fails

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •