Install the chat widget on Shopify
-
In the agent app, open Settings > Website widget and copy the install code.
Install code <!-- Click2Reply chat widget --><script>window.__c2r = {"license":12345678};;(function(w,d,n){if(w[n])return;var q=[],f=function(m){return function(){q.push([m,[].slice.call(arguments)])}};w[n]={_q:q,on:f("on"),once:f("once"),off:f("off"),call:f("call"),get:function(){throw new Error("[Click2Reply] get() is available after the widget loads")},init:function(){var s=d.createElement("script");s.async=!0;s.src="https://w.click2reply.com/w.js";d.head.appendChild(s)}};!(w.__c2r&&w.__c2r.async_init)&&w[n].init()})(window,document,"Click2Reply");</script><noscript><a href="https://w.click2reply.com/page?license=12345678" rel="nofollow">Chat with our support team</a></noscript> -
In Shopify admin, open Online Store > Themes, then on your live theme open the … menu and choose Edit code.
-
Open
layout/theme.liquidand paste the code just before</body>. -
Save, then open your store to see the chat button.
Show agents the cart
Section titled “Show agents the cart”Agents see a shopper’s cart next to the chat when the page tells the widget about it. Add this
after the install code in theme.liquid; Shopify fills the values in. call works before the
widget has loaded too: the call waits and runs once it has.
<script> Click2Reply.call("set_cart", { value: {{ cart.total_price | divided_by: 100.0 }}, currency: {{ cart.currency.iso_code | json }}, items: {{ cart.item_count }} });</script>value is in the currency’s main unit, so 19.99 for 19.99 USD.
A signed-in customer
Section titled “A signed-in customer”When a customer is signed in, pass their name and email so agents do not have to ask:
{% if customer %}<script> Click2Reply.call("set_customer_name", {{ customer.name | json }}); Click2Reply.call("set_customer_email", {{ customer.email | json }});</script>{% endif %}