X ads pixel code for Purchase Event

X ads pixel code for Purchase Event

ajsmith227
New Member
5 0 0

Having a hard getting purchase info back to X ads with pixel code. Site vists/lands working fine. See anything wrong in my code? 

 

 

 

 

 

 

!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);
},s.version="1.1",s.queue=[],u=t.createElement(n),u.async=!0,u.src="https://static.ads-twitter.com/uwt.js",
a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,"script");

twq("config", "myaccount");

analytics.subscribe("checkout_completed", (event) => {
  twq('event', 'purchasecode', {
    'value': event.data.checkout.subtotalPrice.amount,
    'currency': event.data.checkout.currencyCode,
    'email_address': event.data.checkout.email,
    'contents': contents,
    'conversion_id': order.number, 
    'phone_number': order.customer.phone
  });
});

 

 

 

 

 

 

Reply 1 (1)

thebigcagency
Shopify Partner
17 0 6

The contents, conversion_id, phone_number values seem sketchy unless you defined them as variables earlier in the code. For example, the correct notation for the order_id should be

 

'conversion_id': event.data.checkout.order.id

 

Second of all: Does this event work for other non-twitter scripts? You could maybe check with a console.log in the subscribe function and a test order.

Web: https://thebigc-agency.de | LinkedIn: https://www.linkedin.com/in/christophkleine/
Please mark as solution if my comment was able to help with your problem.