Realtime Tracking Listing Analytics
At Smart Shopper Online, our Smart Track Analytics enables us to track the effectiveness of your online listing. This smart tool can track and help us understand the behavior of our online visitors and how they interact with your listing properties (online ad, coupons, social channels,…). The Smart Track Analytics itself gives us the ability to measure the effectiveness of your online campaigns in terms of what coupons bring visitors to your “front door”, how many monthly visitors, listing online clicks. Please enter your coupon tracking code that has been redeem by your client. We take care of rest.
[insert_php]
if (isset($_POST[‘redeem_code’])) {
$mon = strtolower(date(‘F’));
$year = strtolower(date(‘Y’));
$con = mysqli_connect(“localhost”,”amg_user”,”n8J@Z2pHIw”,”smartshopper”);
//on connection failure, throw an error
if(!$con) {
die(‘Could not connect: ‘.mysql_error());
}
$redeem_code = $_POST[‘redeem_code’];
$sql = “SELECT * FROM wp_ss_postmeta WHERE meta_value = ‘”.$redeem_code.”‘ “;
$get_coupon = mysqli_query($con,$sql);
if (mysqli_num_rows($get_coupon) > 0) {
while($row = mysqli_fetch_assoc($get_coupon)) {
$result = $row[‘meta_value’];
$db_post_id = $row[‘post_id’];
$db_coupon_name = $row[‘meta_key’];
}
} else {
$result = “”;
$error = “Incorrect Code!”;
}
if(!empty($result)){
$number_redeem = (int)$_POST[‘number_redeem’];
$sql_query_count = “SELECT count FROM wp_ss_coupon_count WHERE (post_id = ‘”.$db_post_id.”‘ and month = ‘”.$mon.”‘ and year = ‘”.$year.”‘ and count_type = ‘coupon_code’ and coupon_code = ‘”.$db_coupon_name.”‘)”;
$get_count = mysqli_query($con,$sql_query_count);
if (mysqli_num_rows($get_count) > 0) {
while($count_result = mysqli_fetch_assoc($get_count)) {
$new_count = (int)$count_result[‘count’] + $number_redeem;
$sql=”UPDATE wp_ss_coupon_count SET count='”.$new_count.”‘ WHERE post_id = ‘”.$db_post_id.”‘ and month = ‘”.$mon.”‘ and year = ‘”.$year.”‘ and count_type = ‘coupon_code’ and coupon_code = ‘”.$db_coupon_name.”‘ “;
mysqli_query($con,$sql);
$success = “This code has been tracked!”;
}
} else {
$count = $number_redeem;
$sql=”INSERT INTO wp_ss_coupon_count ( post_id , count_type, count, coupon_code, month, year ) VALUES ( ‘$db_post_id’,’coupon_code’, ‘$count’, ‘$db_coupon_name’, ‘$mon’, ‘$year’)”;
mysqli_query($con,$sql);
$success = “This code has been tracked!”;
}
}
}
if($error) {
echo ‘
‘;
} else if($success) {
echo ‘
‘;
}
[/insert_php]