Problem with Convention Script for Greek Price Comparison - Skroutz.gr

Tourist
4 0 1

Hello. 

I try to install the code that skroutz.gr (a price comparison site from greece ) on the thank you page as they want from me to do. 

 

I tried but cant complete it. 

This is the script i put in.

<script>
  sa('ecommerce', 'addOrder', JSON.stringify({
    order_id: '{{ order.name }}',   // Order ID. Required.
    revenue:  '{{ order.total_price}}',  // Grand Total. Includes Tax and Shipping. Does not include payment costs.
    shipping: '{{ order.shipping_price }}',     // Total Shipping Cost. Does not include payment costs.
    tax:      '{{ order.tax_price }}'    // Total Tax.
  }));
</script>
<script>
  sa('ecommerce', 'addItem', JSON.stringify({
    order_id:   '{{ order.name }}',                                    // Order ID. Required.
    product_id: '{{ line_item.product_id }}',                                    // Product ID. Required.
    name:       '{{ line_item.title }}',  // Product Name. Required.
    price:      '{{ line_item.price }}',                                    // Price per Unit. Required.
    quantity:   '{{ cart.item_count }}'                                          // Quantity of Items. Required.
  }));
</script>

it works only this part.  

<script>
  sa('ecommerce', 'addOrder', JSON.stringify({
    order_id: '{{ order.name }}',   // Order ID. Required.
    revenue:  '{{ order.total_price}}',  // Grand Total. Includes Tax and Shipping. Does not include payment costs.
    shipping: '{{ order.shipping_price }}',     // Total Shipping Cost. Does not include payment costs.
    tax:      '{{ order.tax_price }}'    // Total Tax.
  }));
</script>

this is the instruction of the company. https://developer.skroutz.gr/analytics/

 

can you help me please? 

​​​​​​​

1 Like
Shopify Expert
266 0 12

Hey,

Should be an easy solution. Just do a loop:

{% for line_item in order.line_item%}

all the necessary code

{% endfor %}

 

Best,

Jarvis

Jarvis @ Kaleido
- Slow Shopify Store? Install our PageSpeed Magic app.
- Have more questions? Feel free to email me.
- My reply helped? Click Like to show me some love!

0 Likes
Highlighted
Tourist
6 0 0

Hi,

 

I am on the same situation as you are. Did you managed to solve it?

 

I have done the following:

1. I put your <script>...</script> that you provided in the Setting > Checkout > Additional Scripts

 

2. I also added a line in the 2nd <script>

<script>
    ....
    order.forEach(addItem);
</script>

 

3. I have added the <script>...</script> with my SA in theme.liquid

 

But doesn't seem to work all the way through. Any ideas?

 

I am wondering if I have to create a Snippet with PHP code and call it before all that?

 

Thanks in advance,

John

0 Likes