Home > Paid Traffic Sources > Mobile

FREE Mobile Tracking Tool (12)


02-24-2012 10:07 PM #1 hmate9 (Member)
FREE Mobile Tracking Tool

Ok, so here is a tool that I coded to track my Jumptap campaigns.

Firstly, make sure when you create your ads you tick "Yes" for append tracking parameters to destination URL like so:



Next, you need to create a mySQL database. To do this, go into your cPanel and simply click "MySQL databse wizard"

Give your database a name:



Create a username (just use the same name as the name you've used for the database itself):



And that tick "All privileges" and your done!



Next step is to open up "phpmyadmin" from your cpanel and find the databse you've just created from the left hand side. Click on it and you should see this:



At the top, click "Import" and import this file: http://freebigbrandrewards.com/stm/database.sql

Leave everything else as it is and click "Go" at the bottom of the page.

You should see five new tables added to your database:



Ok, now we've set this up. Next step is to go to your landing page, and insert the following code (note: your landing page MUST be in php):

[PHP]<?php
$keyword = $_GET['jt-keyword'];
$handset = $_GET['jt-handset'];
$site = $_GET['jt-site'];
$operator = $_GET['jt-operator'];
$adbundle = $_GET['jt-adbundle'];

$con = mysql_connect("localhost","DATABASE_USERNAME","USE RNAME PASSWORD");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("DATABASE_NAME", $con);

// Store keyword

$result = mysql_query("SELECT * FROM Keyword
WHERE Keyword='$keyword'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Keyword'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nhit = $dbhits + 1;

if($dbkwrd!=''){
mysql_query("UPDATE Keyword SET Hits = '$nhit'
WHERE Keyword = '$keyword'");
}
else{
mysql_query("INSERT INTO Keyword (Keyword, Hits, Clicks)
VALUES ('$keyword', '1', '0')");
}


// Stored keyword

// Store handset

$result = mysql_query("SELECT * FROM Handset
WHERE Handset='$handset'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Handset'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nhit = $dbhits + 1;

if($dbkwrd!=''){
mysql_query("UPDATE Handset SET Hits = '$nhit'
WHERE Handset = '$handset'");
}
else{
mysql_query("INSERT INTO Handset (Handset, Hits, Clicks)
VALUES ('$handset', '1', '0')");
}

// Stored handset

// Store site

$result = mysql_query("SELECT * FROM Site
WHERE Site='$site'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Site'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nhit = $dbhits + 1;

if($dbkwrd!=''){
mysql_query("UPDATE Site SET Hits = '$nhit'
WHERE Site = '$site'");
}
else{
mysql_query("INSERT INTO Site (Site, Hits, Clicks)
VALUES ('$site', '1', '0')");
}

// Stored site

// Store operator

$result = mysql_query("SELECT * FROM Operator
WHERE Operator='$operator'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Operator'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nhit = $dbhits + 1;

if($dbkwrd!=''){
mysql_query("UPDATE Operator SET Hits = '$nhit'
WHERE Operator = '$operator'");
}
else{
mysql_query("INSERT INTO Operator (Operator, Hits, Clicks)
VALUES ('$operator', '1', '0')");
}

// Stored operator

// Store adbundle

$result = mysql_query("SELECT * FROM Adbundle
WHERE Adbundle='$adbundle'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Adbundle'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nhit = $dbhits + 1;

if($dbkwrd!=''){
mysql_query("UPDATE Adbundle SET Hits = '$nhit'
WHERE Adbundle = '$adbundle'");
}
else{
mysql_query("INSERT INTO Adbundle (Adbundle, Hits, Clicks)
VALUES ('$adbundle', '1', '0')");
}

// Stored adbundle

mysql_close($con);

?>[/PHP]

You'll have to change three things in that code:

DATABASE_USERNAME: The username of the database which you've created using the mysql wizard in step 2.
USERNAME PASS: It's password
DATABASE_NAME: Your database's name.

Now, when someone visits your landing page from a jumptap ad, it will store that info into the database which you can later review using phpmyadmin.

Next step. We need to track the clicks! So, what you need to do, is to make a new PHP file and send your clicks FROM your landing page to that PHP document.

Let's call that file "continue.php"

[PHP]<?php

$url = "URL";

$header=$_GET['header'];

$keyword=$_GET['keyword'];

$handset=$_GET['handset'];

$site=$_GET['site'];

$operator=$_GET['operator'];

$adbundle=$_GET['adbundle'];

$con = mysql_connect("localhost","DATABASE_USERNAME","USE R PASSWORD");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("DATABASE NAME", $con);

// Store keyword

$result = mysql_query("SELECT * FROM Keyword
WHERE Keyword='$keyword'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Keyword'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nclicks = $dbclicks + 1;

mysql_query("UPDATE Keyword SET Clicks = '$nclicks'
WHERE Keyword = '$keyword'");

// Stored keyword

// Store handset

$result = mysql_query("SELECT * FROM Handset
WHERE Handset='$handset'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Handset'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nclicks = $dbclicks + 1;

mysql_query("UPDATE Handset SET Clicks = '$nclicks'
WHERE Handset = '$handset'");

// Stored handset

// Store site

$result = mysql_query("SELECT * FROM Site
WHERE Site='$site'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Site'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nclicks = $dbclicks + 1;

mysql_query("UPDATE Site SET Clicks = '$nclicks'
WHERE Site = '$site'");

// Stored site

// Store operator

$result = mysql_query("SELECT * FROM Operator
WHERE Operator='$operator'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Operator'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nclicks = $dbclicks + 1;

mysql_query("UPDATE Operator SET Clicks = '$nclicks'
WHERE Operator = '$operator'");

// Stored operator

// Store adbundle

$result = mysql_query("SELECT * FROM Adbundle
WHERE Adbundle='$adbundle'");

while($row = mysql_fetch_array($result))
{
$dbkwrd = $row['Adbundle'];
$dbhits = $row['Hits'];
$dbclicks = $row['Clicks'];
}

$nclicks = $dbclicks + 1;

mysql_query("UPDATE Adbundle SET Clicks = '$nclicks'
WHERE Adbundle = '$adbundle'");

// Stored adbundle


mysql_close($con);

echo '
<head>
<meta http-equiv="REFRESH" content="0;url'.$url.'"></head>
';

echo 'Redirecting. <a href="'.$url.'">Click here if not redirected.</a>';


?>

[/PHP]

You'll have to change four things in that code:

URL: The URL where you want to send traffic to i.e. the offer from a network.
DATABASE_USERNAME: The username of the database which you've created using the mysql wizard in step 2.
USERNAME PASS: It's password
DATABASE_NAME: Your database's name.

DONE!

Now that your tracking is done, you can monitor the results from phpmyadmin.

NOW HIT DAT THANKS BUTTON!

On a final note:


02-24-2012 10:14 PM #2 Mr Green (Administrator)

+ Thanks for the effort!

Are you able to show a sample of data that shows up in phpmyadmin?


02-24-2012 10:21 PM #3 hmate9 (Member)

Sure!

For example, here is a sample data from my "Keyword" table:



From this, I can see which category gets the most click trough. This is how it looks like for every table.


02-24-2012 10:50 PM #4 bbrock32 (Administrator)

Thanks for taking the time to write this up.

With a little PHP to code a GUI this would be great for people starting out.


02-24-2012 10:51 PM #5 hmate9 (Member)

Give me ideas, tell me improvements and I'll have it done by tomorrow.


02-24-2012 10:56 PM #6 ackbar22000 (Member)

nice script. you could easily make it global for different networks if you were not using the hardcoded JT params. thanx for sharing


02-25-2012 02:04 AM #7 doryphoros (Member)

awesome. thanks a lot man


02-25-2012 07:34 AM #8 wright (Member)

I have some feature requests:

  1. Read up on SQL Injection and how to prevent it
  2. Give the ability to look at date ranges
  3. Do your best to prevent duplicate keys in your code (not select * then while fetchrow)
  4. Do some load testing and see home the code performs when 100 people hit it at once and what it does to the response time


Good luck!


02-25-2012 09:48 AM #9 hmate9 (Member)

^^ alright. Some good stuff there.


02-25-2012 01:51 PM #10 netspace (Member)

Good stuff h,

Might be a dumb question - but can the script be used on other traffic sources ?


02-25-2012 04:35 PM #11 syfy (Member)

Quote Originally Posted by hmate9 View Post
Give me ideas, tell me improvements and I'll have it done by tomorrow.
well this may not be an easy task, but i believe all smartphones use html5 compliant browsers and thus support local storage.

1) go through the source code of p202, and find every reference to it dropping the t202 tracking cookie.
2) In addition to it dropping the cookie using php's setcookie function, also write it out to the browsers's local storage method via JS.
3) Any check for that cookie in prosper202, also check to see if the local storage key has been written and do whatever logic that p202 is suppose to do with that cookie.

this way you get all the benefits of p202 and then have support for smartphones.


02-25-2012 06:59 PM #12 hmate9 (Member)

^ i'll try my best


Home > Paid Traffic Sources > Mobile