JAVASCRIPT 26
Track.js Guest on 19th April 2021 08:03:12 PM
  1. var trackdata = {};
  2. var code = 0;
  3. var isMobile = 0;
  4.  
  5. function getUrlVars() {
  6.     var vars = [],
  7.         hash;
  8.     var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
  9.     for (var i = 0; i < hashes.length; i++) {
  10.         hash = hashes[i].split('=');
  11.         vars.push(hash[0]);
  12.         vars[hash[0]] = hash[1];
  13.     }
  14.     return vars;
  15. }
  16.  
  17. function storeData() {
  18.     urlVars = getUrlVars();
  19.     trackdata.subid = urlVars["subid"] || urlVars["gclid"] || "0";
  20.     trackdata.campaignId = urlVars["campaign_id"] || "0";
  21.     trackdata.publisherName = urlVars["publisher_name"] || "0";
  22.     trackdata.affiliate_id = !!urlVars["gclid"] ? "google" : urlVars["affiliate_id"] || "0";
  23.     $.get("https://kes.globalaqa.com/tracking/api/cmconversiontracking/affiliates/" + trackdata.affiliate_id + "/clicks/" + trackdata.subid + "/landed", trackdata);
  24. };
  25.  
  26. function getDevice() {
  27.     isMobile = {
  28.         Android: function() {
  29.             return navigator.userAgent.match(/Android/i);
  30.         },
  31.         BlackBerry: function() {
  32.             return navigator.userAgent.match(/BlackBerry/i);
  33.         },
  34.         iOS: function() {
  35.             return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  36.         },
  37.         iPhone: function() {
  38.             return navigator.userAgent.match(/iPhone/i);
  39.         },
  40.         iPad: function() {
  41.             return navigator.userAgent.match(/iPad/i);
  42.         },
  43.         Opera: function() {
  44.             return navigator.userAgent.match(/Opera Mini/i);
  45.         },
  46.         Windows: function() {
  47.             return navigator.userAgent.match(/IEMobile/i);
  48.         },
  49.         any: function() {
  50.             return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
  51.         }
  52.     };
  53. };
  54.  
  55.  
  56. $(document).ready(function() {
  57.     getUrlVars();
  58.     storeData();
  59. });

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.