Advertisement
snegir

jus correct code shopify

Dec 17th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. <!-- Insights -->
  2. <script>
  3. window._ssstats = window._ssstats || [];
  4. _ssstats.push([
  5. 'configure', {
  6. accountId: 512585
  7. }
  8. ]);
  9. </script>
  10. <script src="//cdn.statstrk01.com/assets/javascripts/sdk2.js" async></script>
  11. <script type="text/javascript">
  12.  
  13. function setCookie(name, value, options) {
  14. options = options || {};
  15.  
  16. var expires = options.expires;
  17.  
  18. if (typeof expires == "number" && expires) {
  19. var d = new Date();
  20. d.setTime(d.getTime() + expires * 1000);
  21. expires = options.expires = d;
  22. }
  23. if (expires && expires.toUTCString) {
  24. options.expires = expires.toUTCString();
  25. }
  26.  
  27. value = encodeURIComponent(value);
  28.  
  29. var updatedCookie = name + "=" + value;
  30.  
  31. for (var propName in options) {
  32. updatedCookie += "; " + propName;
  33. var propValue = options[propName];
  34. if (propValue !== true) {
  35. updatedCookie += "=" + propValue;
  36. }
  37. }
  38.  
  39. document.cookie = updatedCookie;
  40. }
  41.  
  42.  
  43. function getCookie(name) {
  44. var matches = document.cookie.match(new RegExp(
  45. "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
  46. ));
  47. return matches ? decodeURIComponent(matches[1]) : undefined;
  48. }
  49.  
  50. var products = [];
  51. i = 0;
  52. {% for item in checkout.line_items %}
  53. products[i] = {
  54. 'ImageURL': 'http:{{ item | img_url: 'small' }}',
  55. 'Name': {{ item.product.title | json }},
  56. 'ProductURL': '{{ shop.url }}{{ item.product.url }}',
  57. 'Quantity': '{{ item.quantity }}',
  58. 'Price': '{{ line_item.price | money_without_currency }}',
  59. 'SubTotal': '{{ item.line_price | money_without_currency }}'
  60. }
  61. i++
  62. {% endfor %}
  63. var orderID = getCookie('orderID');
  64. if (document.URL.indexOf('thank_you') != -1) {
  65. _ssstats.push(['identify', {{ checkout.email | json}}]);
  66. _ssstats.push(['publish', 'Order Placed',
  67. {'Items': products,
  68. 'monetaryValue': {{checkout.total_price | money_without_currency}},
  69. 'orderId' : {{ order_number }},
  70. 'newsletter_signup': {{ checkout.buyer_accepts_marketing | json }}
  71. }
  72. ]);
  73. }
  74.  
  75. setCookie('orderID', {{ order_number }});
  76. </script>
  77. <!-- /Insights -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement