Skip to main content

How to fix the non-attributed orders?

If you have a lot of non attributed orders, then this will fix your issue.

Written by Moritz Fenske
Updated over 2 weeks ago

If you have a non-attributed orders, they will show up in the pixel view as following:

If you want to reduce those, you can do it in 2 steps:

Add this script to theme.liquid

<script async src="https://storage.googleapis.com/tp_script/YOURSHOPIFYNAME.myshopify.com/config.js"></script>

Change YOURSHOPIFYNAME with your Shopify shop name.

IMPORTANT: Don't use the name of your shop. Use the Shopify shopname.


Example: This is your admin URL: https://admin.shopify.com/store/acme-demo-store

Then acme-demo-store is your Shopify shop name.

You can also see your shopify shopname in Venon if you click on your shop in the top left. In this example the Shopify shopname is acme-demo-store:

So your final script that you need to add is:

<script async src="https://storage.googleapis.com/tp_script/acme-demo-store.myshopify.com/config.js"></script>

1. Go to Online shops → Themes

2. Click on three dots → Edit code

3. Go to layout → theme.liquid

4. Add it in the header at the top:

5. Then click on Save at the top right

When you're done with this, you just need to do step 2:

Add customer events

1. Go to Shopify settings (bottom left)

2. Go to Customer events

3. Add custom pixel

​​

4. Add name Venon

​​

5. Set settings

Permission: Not required

Data sale: Data collected does not qualify as data sale

​​

6. Add this code:

Replace YOURSHOPIFYNAME with your Shopify name here. So for example: const shopName = "test"; Keep the quotes before and after ("...").

const shopName="YOURSHOPIFYNAME";
function t(t){return{product_id:t.merchandise?.product?.id?.replace("gid://shopify/Product/","")||"",variant_id:t.merchandise?.id?.replace("gid://shopify/ProductVariant/","")||"",title:t.merchandise?.product?.title||t.merchandise?.title||"",price:t.cost?.totalAmount?.amount||t.merchandise?.price?.amount||0,quantity:t.quantity||1,image_url:t.merchandise?.image?.src||null,url:t.merchandise?.product?.url||null}}function e(t){return(t.lineItems||[]).slice(0,10).map(t=>({product_id:t.variant?.product?.id?.replace("gid://shopify/Product/","")||"",variant_id:t.variant?.id?.replace("gid://shopify/ProductVariant/","")||"",title:t.title||t.variant?.title||"",price:t.variant?.price?.amount||0,quantity:t.quantity||1,image_url:t.variant?.image?.src||null,url:t.variant?.product?.url||null}))}function n(t){if(!t)return null;try{const e=atob(t);return JSON.parse(e).$exchange_id||null}catch(e){return null}}function r(t){const n={checkoutId:t?.token,value:t?.totalPrice?.amount,currency:t?.totalPrice?.currencyCode,email:t?.email||null,phone:t?.phone||null};return t?.lineItems&&(n.line_items=e(t),n.item_count=t.lineItems.reduce((t,e)=>t+(e.quantity||1),0),n.cart_total=t.totalPrice?.amount),n}function a(t){const e=new URL(t.context.document.location.href),n=""!==e.searchParams.toString(),r=t.context.document.referrer,a=""!==r,i=a&&new URL(r).hostname===e.hostname,c=t.context.document.location.href.includes("checkouts"),o=t.context.document.location.href.includes("/orders/");return n||a&&!i||c||o?{}:null}function i(t){const e=t.data.productVariant;return{currency_code:e?.price?.currencyCode,brand:e?.product?.vendor,url:e?.product?.url,image_url:e?.image?.src,product_id:e?.product?.id,value:e?.price?.amount,product_name:e?.product?.title}}function c(e){const n=e.data?.cartLine;return n?{value:n.cost?.totalAmount?.amount,currency:n.cost?.totalAmount?.currencyCode,line_items:[t(n)],item_count:n.quantity||1,cart_total:n.cost?.totalAmount?.amount,product_type:n.merchandise?.product?.type,variant_id:n.merchandise?.id,product_id:n.merchandise?.product?.id,variant_sku:n.merchandise?.sku,product_name:n.merchandise?.product?.title,variant_name:n.merchandise?.title,brand:n.merchandise?.product?.vendor,url:n.merchandise?.product?.url,image_url:n.merchandise?.image?.src}:{}}function o(t){const n=t.data?.checkout,r={orderId:n?.order?.id,checkoutId:n?.token,value:n?.totalPrice?.amount,currency:n?.totalPrice?.currencyCode,email:n?.email||null,phone:n?.phone||null,subtotal_price:n?.subtotalPrice?.amount||null};return n?.lineItems&&(r.line_items=e(n),r.item_count=n.lineItems.reduce((t,e)=>t+(e.quantity||1),0)),r}function u(t){const n=t.data?.checkout,r={checkoutId:n?.token,value:n?.totalPrice?.amount,currency:n?.totalPrice?.currencyCode};return n?.lineItems&&(r.line_items=e(n),r.item_count=n.lineItems.reduce((t,e)=>t+(e.quantity||1),0),r.cart_total=n.totalPrice?.amount,r.line_items=n.lineItems?.map(t=>({key:t?.id,quantity:t?.quantity,title:t?.title,price:t?.finalLinePrice?.amount,productId:t?.variant?.product?.id,variantId:t?.variant?.id,variantTitle:t?.variant?.title,variantPrice:t?.variant?.price?.amount,sku:t?.variant?.sku,vendor:t?.variant?.product?.vendor,productType:t?.variant?.product?.type,imageUrl:t?.variant?.image?.src,url:t?.variant?.product?.url}))),n&&(r.customer_locale=n.localization?.language?.isoCode,r.discountCodes=n.discountApplications,r.item_count=n.lineItems?.length,r.items=n.lineItems?.map(t=>t?.title),r.sourceName="web",r.totalDiscounts=n.discountsAmount?.amount,r.value=n.totalPrice?.amount,r.currency=n.currencyCode,r.token=n.token,r.email=n.email,r.phone=n.phone,r.subtotal_price=n.subtotalPrice?.amount,r.totalTax=n.totalTax?.amount,r.shippingPrice=n.shippingLine?.price?.amount),r}async function s(t,e,shopName){if(e)return JSON.parse(e).sessionId;const n=l();return t.cookie.set("dv_sessionId",JSON.stringify({sessionId:n,shopName:shopName})),n}function d(t,e,n,shopName,r,a){const i={name:t.name,sessionId:n,shop_name:shopName,title:e.context.document.title,clientId:t.clientId,timestamp:t.timestamp,page:e.context.document.location.href,referrer:e.context.document.referrer,cartId:r,user_agent:e.context.navigator?.userAgent};return a&&(i.klaviyo_exchange_id=a),i}function l(){const t=new Uint8Array(16);return self.crypto.getRandomValues(t),Array.from(t,t=>("0"+t.toString(16)).slice(-2)).join("")}analytics.subscribe("all_standard_events",async t=>{const e=await browser.cookie.get("dv_sessionId"),l=await browser.cookie.get("__kla_id"),m=await s(browser,e,shopName),p=await browser.cookie.get("cart"),_=n(l);let h={};switch(t.name){case"page_viewed":const e=a(init);if(!e)return;h=e;break;case"product_viewed":h=i(t);break;case"product_added_to_cart":h=c(t);break;case"checkout_completed":h=o(t);break;case"checkout_started":h=u(t);break;case"checkout_address_info_submitted":case"checkout_contact_info_submitted":case"checkout_shipping_info_submitted":case"payment_info_submitted":h=r(t.data?.checkout);break;case"product_removed_from_cart":case"search_submitted":break;default:return}const y={...h,...d(t,init,m,shopName,p,_)};fetch("https://api.venon.io/api/shopifyfeedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(y),keepalive:!0})}
);

Please copy the whole script to your clipboard.

7. Click 'Connect'

Did this answer your question?