Advertisement
snegir

shopify mnartmail

Jun 4th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. <!-- Insights -->
  2. <script>
  3. window._ssstats = window._ssstats || [];
  4. _ssstats.push([
  5. 'configure', {
  6. accountId: 499421 // CHANGE TO YOUR ID
  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. function getCookie(name) {
  43. var matches = document.cookie.match(new RegExp(
  44. "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
  45. ));
  46. return matches ? decodeURIComponent(matches[1]) : undefined;
  47. }
  48.  
  49. var products = [];
  50. i = 0;
  51. {% for item in checkout.line_items %}
  52. products[i] = {
  53. 'ImageURL': 'http:{{ item | img_url: 'small' }}',
  54. 'Name': {{ item.product.title | json }},
  55. 'ProductURL': '{{ shop.url }}{{ item.product.url }}',
  56. 'Quantity': '{{ item.quantity }}',
  57. 'Price': '{{ line_item.price | money_without_currency }}',
  58. 'SubTotal': '{{ item.line_price | money_without_currency }}'
  59. }
  60. i++
  61. {% endfor %}
  62. var orderID = getCookie('orderID');
  63. if (orderID != '{{ order_number }}') {
  64. _ssstats.push(['identify', {{ checkout.email | json}}]);
  65. _ssstats.push(['publish', 'Order Placed',
  66. {'Items': products,
  67. 'monetaryValue': {{checkout.total_price | money_without_currency}},
  68. 'orderId' : {{ order_number }},
  69. 'newsletter_signup': {{ checkout.buyer_accepts_marketing | json }}
  70. }
  71. ]);
  72. }
  73. //localStorage.orderID = {{ order_number }};
  74. setCookie('orderID', {{ order_number }})
  75. </script>
  76. <!-- /Insights -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement