Seguimiento de compras con snippet en Shopify

Introducción

En caso de que en la instalación de la App de Connectif en Shopify se haya seleccionado la opción "Use online purchases" en el apartado "Purchases", será necesario implementar el snippet que permite el seguimiento de las compras en Connectif.

 

shopify_snippet_4.jpg

 

Implementación

En primer lugar hemos de copiar el snippet de seguimiento de las compras adecuado a nuestra configuración:

 

Si hemos marcado la opción de productos con variantes debemos usar este: 

<!-- Start of Connectif Purchase Snippet -->
<div class="cn_purchase" style="display:none">
<span class="cart_id">0</span>
<span class="purchase_id">{{ order.id }}</span>
<span class="purchase_date">{{ order.created_at | date: "%FT%H:%M:%S.%L%z" }}</span>
<span class="total_quantity">{{ order.item_count }}</span>
<span class="total_price">{{ order.total_price | times: 0.01 }}</span>
{% for item in order.line_items %}
<div class="product_basket_item">
<span class="quantity">{{ item.quantity }}</span>
<span class="price">{{ item.final_line_price | times: 0.01 }}</span>
{% if item.variant.title == "Default Title" %}
<span class="name">{{item.product.title | escape}}</span>
{% else %}
<span class="name">{{item.product.title | escape}} {{ item.variant.title | escape }}</span>
{% endif %}
<span class="url">{{ shop.url }}{{ item.product.url }}</span>
<span class="product_id">{{ item.product_id }}</span>
<span class="unit_price">{{ item.final_price | times: 0.01 }}</span>
<span class="published_at">{{ item.product.published_at | date: "%FT%H:%M:%S.%L%z" }}</span>
<span class="image_url">https:{{item.image.src | product_img_url: '300x300' }}</span>
<span class="description">{{item.product.description | strip_html | escape }}</span>
{% assign unit_price_original = item.variant.compare_at_price | at_least: item.final_price %}
<span class="unit_price_original">{{unit_price_original | times: 0.01 }}</span>
{% assign discounted_amount = unit_price_original | minus: item.final_price %}
<span class="discounted_amount">{{discounted_amount | times: 0.01 }}</span>
{% assign percentage_factor = unit_price_original | times: 0.01 %}
{% assign discounted_percentage = discounted_amount | divided_by: percentage_factor | round: 2 %}
<span class="discounted_percentage">{{discounted_percentage}}</span>
{% for collection in item.product.collections %}
<span class="category">{{ collection.title }}</span>
{% endfor %}
{% for tag in item.product.tags %}
<span class="tag">{{ tag }}</span>
{% endfor %}
<span class="brand">{{ item.product.vendor | escape }}</span>
<span class="thumbnail_url">https:{{ item.image.src | product_img_url: '100x100' }}</span>
</div>
{% endfor %}
</div>
<div class="cn_client_info" style="display: none">
<span class="primary_key">{{ order.email }}</span>
<span class="_name">{{ order.customer.first_name }}</span>
<span class="_surname">{{ order.customer.last_name }}</span>
<span class="_mobilePhone">{{ order.customer.phone }}</span>
span class="_newsletter_subscription_status">{% if order.customer.accepts_marketing == true %}subscribed{% else if order.customer.accepts_marketing == false %}unsubscribed{% else %}{% endif %}</span>
</div>
<!-- End of Connectif Purchase Snippet -->

Por el contrario si NO hemos marcado la opción productos con variantes se debe usar el siguiente: 

<!-- Start of Connectif Purchase Snippet -->
<div class="cn_purchase" style="display:none">
<span class="cart_id">0</span>
<span class="purchase_id">{{ order.id }}</span>
<span class="purchase_date">{{ order.created_at | date: "%FT%H:%M:%S.%L%z" }}</span>
<span class="total_quantity">{{ order.item_count }}</span>
<span class="total_price">{{ order.total_price | times: 0.01 }}</span>
{% for item in order.line_items %}
<div class="product_basket_item">
<span class="quantity">{{ item.quantity }}</span>
<span class="price">{{ item.line_price | times: 0.01 }}</span>
<span class="name">{{ item.product.title | escape }}</span>
<span class="url">{{ shop.url }}{{ item.product.url }}</span>
<span class="product_id">{{ item.product_id }}</span>
<span class="unit_price">{{ item.product.price | times: 0.01 }}</span>
<span class="published_at">{{ item.product.published_at | date: "%FT%H:%M:%S.%L%z" }}</span>
</div>
{% endfor %}
</div>
<div class="cn_client_info" style="display: none">
<span class="primary_key">{{ order.email }}</span>
<span class="_name">{{ order.customer.first_name }}</span>
<span class="_surname">{{ order.customer.last_name }}</span>
<span class="_mobilePhone">{{ order.customer.phone }}</span>
span class="_newsletter_subscription_status">{% if order.customer.accepts_marketing == true %}subscribed{% else if order.customer.accepts_marketing == false %}unsubscribed{% else %}{% endif %}</span>
</div>
<!-- End of Connectif Purchase Snippet -->

Copiamos volvemos al admin de la tienda de  Shopify y nos dirigimos a "Settings > Checkout > Order Status Page", donde pegaremos el código que acabamos de copiar.

mceclip0.png

mceclip1.png

mceclip2.png

 

Una vez copiado, hacemos clic en "Save" y ya estará listo Shopify para pasar las compras a Connectif.

Nota

En el caso en que se deshabilite o desinstale la app de Connectif, el snippet no se eliminará.

¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0