Skip to content

Instantly share code, notes, and snippets.

@bani
Last active August 29, 2015 14:04
Show Gist options
  • Save bani/4e3fd2d4b462a8499c89 to your computer and use it in GitHub Desktop.
Save bani/4e3fd2d4b462a8499c89 to your computer and use it in GitHub Desktop.

Revisions

  1. bani revised this gist Jul 20, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ga-ec-transactions.liquid
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ ga('ec:addProduct', {
    'category': '{{line_item.product.type}}',
    'brand': '{{line_item.vendor}}',
    'variant': '{{line_item.variant.option1}} {{line_item.variant.option2}} {{line_item.variant.option3}}',
    'price': '{{line_item.price}}',
    'price': '{{line_item.price | money_without_currency}}',
    'quantity': {{line_item.quantity}}
    });
    {% endfor %}
  2. bani revised this gist Jul 20, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions ga-ec-transactions.liquid
    Original file line number Diff line number Diff line change
    @@ -12,9 +12,9 @@ ga('ec:addProduct', {
    {% endfor %}
    ga('ec:setAction', 'purchase', {
    'id': '{{order.order_number}}',
    'revenue': '{{order.total_price}}',
    'tax': '{{order.tax_price}}',
    'shipping': '{{order.shipping_price}}',
    'revenue': '{{order.total_price | money_without_currency}}',
    'tax': '{{order.tax_price | money_without_currency}}',
    'shipping': '{{order.shipping_price | money_without_currency}}',
    'coupon': '{% for discount in order.discounts %}{{discount.code}}{% endfor %}'
    });
    </script>
  3. bani revised this gist Jul 20, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ga-ec-transactions.liquid
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    {% for line_item in order.line_items %}
    ga('ec:addProduct', {
    'id': '{{line_item.id}}',
    'name': '{{line_item.title}}',
    'name': '{{line_item.product.title}}',
    'category': '{{line_item.product.type}}',
    'brand': '{{line_item.vendor}}',
    'variant': '{{line_item.variant.option1}} {{line_item.variant.option2}} {{line_item.variant.option3}}',
  4. bani renamed this gist Jul 20, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion transactions.liquid → ga-ec-transactions.liquid
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <script type="text/javascript">
    {% for line_item in order.line_items %}
    ga('ec:addProduct', {
    'id': '{{line_item.id}}',
    @@ -15,4 +16,5 @@ ga('ec:setAction', 'purchase', {
    'tax': '{{order.tax_price}}',
    'shipping': '{{order.shipping_price}}',
    'coupon': '{% for discount in order.discounts %}{{discount.code}}{% endfor %}'
    });
    });
    </script>
  5. bani revised this gist Jul 20, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion transactions.liquid
    Original file line number Diff line number Diff line change
    @@ -14,5 +14,5 @@ ga('ec:setAction', 'purchase', {
    'revenue': '{{order.total_price}}',
    'tax': '{{order.tax_price}}',
    'shipping': '{{order.shipping_price}}',
    'coupon': '{% for discount in order.discounts %}{{discount.code}} {% endfor %}'
    'coupon': '{% for discount in order.discounts %}{{discount.code}}{% endfor %}'
    });
  6. bani revised this gist Jul 20, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions transactions.liquid
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@
    ga('ec:addProduct', {
    'id': '{{line_item.id}}',
    'name': '{{line_item.title}}',
    'category': 'Apparel',
    'category': '{{line_item.product.type}}',
    'brand': '{{line_item.vendor}}',
    'variant': '{{line_item.variant.option1}}/{{line_item.variant.option2}}',
    'variant': '{{line_item.variant.option1}} {{line_item.variant.option2}} {{line_item.variant.option3}}',
    'price': '{{line_item.price}}',
    'quantity': {{line_item.quantity}}
    });
    @@ -14,5 +14,5 @@ ga('ec:setAction', 'purchase', {
    'revenue': '{{order.total_price}}',
    'tax': '{{order.tax_price}}',
    'shipping': '{{order.shipping_price}}',
    'coupon': '{% for discount in order.discounts %}{{discount.code}}{% endfor %}'
    'coupon': '{% for discount in order.discounts %}{{discount.code}} {% endfor %}'
    });
  7. bani renamed this gist Jul 20, 2014. 1 changed file with 0 additions and 0 deletions.
  8. bani created this gist Jul 20, 2014.
    18 changes: 18 additions & 0 deletions Enhanced Ecommerce Transactions Liquid
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    {% for line_item in order.line_items %}
    ga('ec:addProduct', {
    'id': '{{line_item.id}}',
    'name': '{{line_item.title}}',
    'category': 'Apparel',
    'brand': '{{line_item.vendor}}',
    'variant': '{{line_item.variant.option1}}/{{line_item.variant.option2}}',
    'price': '{{line_item.price}}',
    'quantity': {{line_item.quantity}}
    });
    {% endfor %}
    ga('ec:setAction', 'purchase', {
    'id': '{{order.order_number}}',
    'revenue': '{{order.total_price}}',
    'tax': '{{order.tax_price}}',
    'shipping': '{{order.shipping_price}}',
    'coupon': '{% for discount in order.discounts %}{{discount.code}}{% endfor %}'
    });