Advertisement
Guest User

Untitled

a guest
May 24th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     /**
  3.      * Set cookie to user
  4.      *
  5.      * @param cname - Cookie name
  6.      * @param cvalue - Cookie value
  7.      * @param exdays - Cookie life time
  8.      */
  9.     function setCookie(cname, cvalue, exdays) {
  10.         var d = new Date();
  11.         d.setTime(d.getTime() + (exdays * 1000));
  12.         var expires     = "expires=" + d.toUTCString();
  13.         document.cookie = cname + "=" + cvalue + "; " + expires;
  14.     }
  15.  
  16.     /**
  17.      * Get user's cookie by name
  18.      *
  19.      * @param cname - Cookie name
  20.      */
  21.     function getCookie(cname) {
  22.         var name = cname + "=";
  23.         var ca   = document.cookie.split(';');
  24.  
  25.         for (var i = 0; i < ca.length; i++) {
  26.             var c = ca[i];
  27.  
  28.             while (c.charAt(0) == ' ') {
  29.                 c = c.substring(1);
  30.             }
  31.  
  32.             if (c.indexOf(name) == 0) {
  33.                 return c.substring(name.length, c.length);
  34.             }
  35.         }
  36.  
  37.         return "";
  38.     }
  39.  
  40.     var orderIdFromCookie = getCookie("orderIdFromCookie");
  41.  
  42.     var totalProfitUSD = myOrder.totalPriceUSD - (myOrder.taxUSD + myOrder.affiliateCommissionUSD); // Total profit without taxes and affil commission
  43.     var refNumber      = myOrder.refNo; // Reference number
  44.     var totalPriceUSD  = myOrder.totalPriceUSD; // Price in USD, including tax and commission
  45.     var orderProducts  = myOrder.productsInOrder;
  46.  
  47.     // Check if user's cookie is not set yet and has another value from current reference number
  48.     if (orderIdFromCookie == "" || orderIdFromCookie == undefined || orderIdFromCookie != refNumber) {
  49.         var google_conversion_id       = 980763043; // AdWords account id. English account
  50.         var google_conversion_language = "en"; // // AdWords conversion language
  51.         var google_conversion_format   = "3"; // Don't show Google notification to user
  52.         var google_conversion_color    = "ffffff";
  53.         var google_conversion_label    = "dusiCL2G2AgQo4PV0wM"; // Generated conversion label from AdWords account
  54.         var google_conversion_value    = totalProfitUSD; // Save total profit as conversion value
  55.         var google_conversion_currency = "USD";
  56.         var google_remarketing_only    = false; // Don't use remarketing to save record as conversion
  57.         var google_conversion_order_id = refNumber; // Order id is order's reference number
  58.  
  59.         // Call AdWords script for each set of variables to transmit conversion
  60.         document.write("<script type='text/javascript' src='//www.googleadservices.com/pagead/conversion.js'><\/script>");
  61.  
  62.         var google_conversion_id    = 950091228; // Russian account
  63.         var google_conversion_label = "l8h_CNaaz14Q3PuExQM";
  64.  
  65.         document.write("<script type='text/javascript' src='//www.googleadservices.com/pagead/conversion.js'><\/script>");
  66.  
  67.         var google_conversion_id    = 946482587;
  68.         var google_conversion_label = "MIbSCISM6V0Qm9uowwM";
  69.  
  70.         document.write("<script type='text/javascript' src='//www.googleadservices.com/pagead/conversion.js'><\/script>");
  71.  
  72.         var yahoo_conversion_id    = 1000056483; // Yahoo account id
  73.         var yahoo_conversion_label = "w9MuCMGQvAQQ18-J2AM"; // Generated conversion label from Yahoo account
  74.         var yahoo_conversion_value = totalProfitUSD; // Save total profit as conversion value
  75.  
  76.         // Call Yahoo script to transmit conversion
  77.         document.write("<script type='text/javascript' src='https://s.yimg.jp/images/listing/tool/cv/conversion.js'><\/script>");
  78.  
  79.         if (!window.mstag) { // If we don't have global Microsoft tag, create it
  80.             mstag = {
  81.                 loadTag: function () {
  82.                 }, time: (new Date()).getTime()
  83.             };
  84.         }
  85.  
  86.         // Transmit Microsoft mstag
  87.         document.write("<script id='mstag_tops' type='text/javascript' src='//flex.msn.com/mstag/site/61892fcd-7a56-412c-9ad2-04812f0a4ceb/mstag.js'><\/script>");
  88.  
  89.         mstag.loadTag("analytics", {
  90.             dedup: "1",
  91.             domainId: "2987864",
  92.             type: "1",
  93.             revenue: totalProfitUSD,
  94.             actionid: "235605"
  95.         });
  96.  
  97.         // Transmit Microsoft conversion
  98.         document.write(<iframe
  99.                 src="//flex.msn.com/mstag/tag/61892fcd-7a56-412c-9ad2-04812f0a4ceb/analytics.html?dedup=1&domainId=2987864&type=1&revenue=&actionid=235605"
  100.                 frameborder="0" scrolling="no" width="1" height="1" style="visibility:hidden;display:none"></iframe>);
  101.  
  102.  
  103.         ga('require', 'ecommerce', 'ecommerce.js');
  104.         ga('ecommerce:addTransaction', {
  105.             'id': refNumber,          // Order ID
  106.             'name': myOrder.idAffiliate,    // Affiliation
  107.             'revenue': totalProfitUSD,  // Total
  108.             'shipping': myOrder.shippingUSD,    // Shipping
  109.             'tax': myOrder.taxUSD         // Tax
  110.         });
  111.  
  112.         var yaMetricProducts = '['; // String with products for Yandex
  113.  
  114.         for (i = 0; i < orderProducts.length; i++) { // Run for each product in order
  115.             ga('ecommerce:addItem', {
  116.                 'id': refNumber,                          // Order ID
  117.                 'name': orderProducts[i].name,        // Product Name
  118.                 'sku': orderProducts[i].id,          // SKU
  119.                 'category': orderProducts[i].category,    // Category
  120.                 'price': orderProducts[i].priceUSD,    // Price
  121.                 'quantity': orderProducts[i].quantity     // Quantity
  122.             });
  123.  
  124.             // Yandex metrics
  125.             yaMetricProducts = yaMetricProducts + '{"id": "' + refNumber + '",  "name": "' + orderProducts[i].name + '", "price" :' + orderProducts[i].priceUSD + ', "quantity": ' + orderProducts[i].quantity + '}';
  126.  
  127.             if (i != orderProducts.length - 1) {
  128.                 yaMetricProducts = yaMetricProducts + ',';
  129.             }
  130.         }
  131.  
  132.         ga('ecommerce:send'); // Send google analytics conversion
  133.  
  134.         yaMetricProducts = yaMetricProducts + ']';
  135.  
  136.         // Send Yandex
  137.         window.dataLayer = window.dataLayer || [];
  138.         window.dataLayer.push({
  139.                                   "ecommerce": {
  140.                                       "currencyCode": "USD",
  141.                                       "purchase": {
  142.                                           "actionField": {
  143.                                               "id": '' + refNumber + '',
  144.                                               "revenue": '' + (totalProfitUSD) + '',
  145.                                               "goal_id": "17918750",
  146.                                           },
  147.                                           "products": JSON.parse(yaMetricProducts)
  148.                                       }
  149.                                   }
  150.                               });
  151.  
  152.         <!-- AdvTransaction.aspx?AdID=12272&SV={TOTAL}&OID={REFNO} -->
  153.         document.write('<img src="https://www.clixGalore.com/AdvTransaction.aspx?AdID=12272&SV=1&OID=1" height="0" width="0" border="0">');
  154.  
  155.         var mvv_order_stts = 1;
  156.  
  157.         // Facebook conversion
  158.         (function () {
  159.             var _fbq = window._fbq || (window._fbq = []);
  160.             if (!_fbq.loaded) {
  161.                 var fbds   = document.createElement('script');
  162.                 fbds.async = true;
  163.                 fbds.src   = '//connect.facebook.net/en_US/fbds.js';
  164.                 var s      = document.getElementsByTagName('script')[0];
  165.                 s.parentNode.insertBefore(fbds, s);
  166.                 _fbq.loaded = true;
  167.             }
  168.         })();
  169.  
  170.         window._fbq = window._fbq || [];
  171.         window._fbq.push(['track', '6024826674544',
  172.                              {'value': '0.00', 'currency': 'USD'}
  173.                          ]);
  174.  
  175.         // Gemini conversion value
  176.         var yahoo_gemini_conversion_value = totalProfitUSD;
  177.  
  178.         // Gather data and send it to Yahoo Gemini
  179.         (function (w, d, t, r, u) {
  180.             w[u] = w[u] || [];
  181.             w[u].push({
  182.                           'projectId': '1000690939019',
  183.                           'properties': {'pixelId': '436970', 'qstrings': {'gv': yahoo_gemini_conversion_value}}
  184.                       });
  185.             var s   = d.createElement(t);
  186.             s.src   = r;
  187.             s.async = true;
  188.  
  189.             s.onload = s.onreadystatechange = function () {
  190.                 var y, rs = this.readyState, c = w[u];
  191.  
  192.                 if (rs && rs != "complete" && rs != "loaded") {
  193.                     return
  194.                 }
  195.  
  196.                 try {
  197.                     y         = YAHOO.ywa.I13N.fireBeacon;
  198.                     w[u]      = [];
  199.                     w[u].push = function (p) {
  200.                         y([p])
  201.                     };
  202.                     y(c)
  203.                 } catch (e) {
  204.                 }
  205.             };
  206.  
  207.             var scr = d.getElementsByTagName(t)[0], par = scr.parentNode;
  208.             par.insertBefore(s, scr);
  209.         })(window, document, "script", "https://s.yimg.com/wi/ytc.js", "dotq");
  210.  
  211.  
  212.         var eut_value = totalProfitUSD;
  213.  
  214.         window.uetq = window.uetq || [];
  215.         window.uetq.push(
  216.                 {'gv': eut_value}
  217.         ); // Pass the computed revenue
  218.  
  219.         // Send conversion to bing
  220.         (function (w, d, t, r, u) {
  221.             var f, n, i;
  222.  
  223.             w[u] = w[u] || [], f = function () {
  224.                 var o =
  225.                     {ti: "5035788"}
  226.                         ;
  227.                 o.q = w[u], w[u] = new UET(o), w[u].push("pageLoad")
  228.             }, n = d.createElement(t), n.src = r, n.async = 1, n.onload = n.onreadystatechange = function () {
  229.                 var s = this.readyState;
  230.                 s && s !== "loaded" && s !== "complete" || (f(), n.onload = n.onreadystatechange = null)
  231.             }
  232.                     , i = d.getElementsByTagName(t)[0], i.parentNode.insertBefore(n, i)
  233.         })(window, document, "script", "//bat.bing.com/bat.js", "uetq");
  234.     }
  235.  
  236.     setCookie("orderIdFromCookie", refNumber, 30 * 24 * 60 * 60);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement