https://netsuiteprofessionals.com logo
#suitecommerce
Title
# suitecommerce
k

Kuldeep Singh

04/06/2022, 2:14 PM
Hi All, I am doing netsuite to Klaviyo integration for abandoned cart(Started Checkout metrics). I have placed the Klaviyo code in order_wizard_cart_summary.tpl and facing problem of multiple instances of same user data in Klaviyo under Started Checkout metrics> activity feed. How to prevent multiple instances of same user data in Klaviyo? Thanks
c

Christopher Dembek

04/06/2022, 2:23 PM
Can you share a sample of the code you are adding to the template?
k

Kuldeep Singh

04/06/2022, 2:41 PM
@Christopher Dembek here is the code: <script type="text/javascript" async src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=xyz_id"></script> <script type="text/javascript"> var _learnq = _learnq || []; "{{#if loggedIn}}" _learnq.push(['identify', {'$email': '{{userEmail}}'}]); "{{/if}}" $(document).ready(function(){ console.log("math.round",typeof Math.round(Date.now() / 1000).toString()); console.log("Date.now",Date.now()); var grandtotal="{{model.summary.total}}"; var event_id = Math.round(Date.now() / 1000).toString(); var subtotal="{{model.summary.subtotal}}"; var shippingamount="{{#if model.summary.shippingcost}}{{model.summary.shippingcost}}{{else}}{{model.summary.estimatedshipping}}{{/if}}"; var url="{{model.touchpoints.viewcart}}"; var currency="USD"; var taxamount="{{model.summary.taxtotal}}"; var discountamount="{{model.summary.discounttotal}}"; var ItemNames = []; var Items = []; var value = subtotal; var checkoutUrl = "{{model.touchpoints.checkout}}"; console.log("checkoutUrl", checkoutUrl); "{{#each model.lines}}" ItemNames.push("{{item._name}}"); var itemObj = {}; itemObj.other="{{#each options}}{{label}}: {{value.label}}, {{/each}}"; itemObj.SKU = "{{item._sku}}"; itemObj.ProductName = "{{item._name}}"; itemObj.Quantity = "{{quantity}}"; itemObj.ItemPrice = "{{rate}}"; itemObj.ProductURL = "{{item.canonicalurl}}"; itemObj.ImageURL = "{{item._thumbnail.url}}"; itemObj.RowTotal = "{{amount}}"; Items.push(itemObj); "{{/each}}" _learnq.push(["track", "Started Checkout", { "$event_id": event_id, "$value": subtotal, "ItemNames": ItemNames, "CheckoutURL": "/sbe-dev-kilimanjaro/checkout.ssp?#shipping/address", "Items": Items }]); }); </script>
c

Christopher Dembek

04/06/2022, 2:51 PM
Have you thought about using Google Tag Manager? Personally, I try to avoid adding an inline script to the template code. Yes, I have had to add inline script code in the past, but it is typically the last option.
👍 1
k

Kuldeep Singh

04/06/2022, 2:56 PM
Thanks @Christopher Dembek
4 Views