Sha256: aeae67027b8f02c7751c38deaf0c3e00c2fd7ea0fa2a7b2707b8c8fa9f382cbb

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

= content_for :javascript do
  javascript:
    if (typeof gtag === "function") {
      gtag('event', 'purchase', {
        "transaction_id": "#{session[:payment_id]}",
        "affiliation": "#{request.host}",
        "value": #{session[:payment_price]},
        "currency": "USD",
        "tax": 0,
        "shipping": 0,
        "items": [
          {
            "id": "#{@order ? @order.id : session[:payment_title]}",
            "name": "#{session[:payment_title]}",
            "category": "#{@order ? @order.service_title : 'translation'}",
            "quantity": 1,
            "price": '#{session[:payment_price]}'
          }
        ]
      });
    } else {
      $(document).ready(function(){
        ga('require', 'ecommerce');

        ga('ecommerce:addTransaction', {
          'id': '#{session[:payment_id]}',                 // Transaction ID. Required.
          'affiliation': '#{request.host}',     // Affiliation or store name.
          'revenue': '#{session[:payment_price]}'// Grand Total.
        });

        ga('ecommerce:addItem', {
          'id': '#{session[:payment_id]}',                 // Transaction ID. Required.
          'name': '#{session[:payment_title]}',           // Product name. Required.
          'sku': '#{ @order ? @order.id : session[:payment_title]}',                // SKU/code.
          'category': "#{@order ? @order.service_title : 'translation'}", // Category or variation.
          'price': '#{session[:payment_price]}', // Unit price.
          'quantity': '1'                           // Quantity.
        });

        ga('ecommerce:send');
      });
    }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/views/payments/integrations/_ecommerce.html.slim