List of Objects

I am writing a list of objects, [{ itemId: number, Qty: number, sku: String }], within a custom HTML action, however when this trigger fires an error " Unexpected identifier ‘Object’ " is thrown.

When running in Debug mode I can see that the action is being evalutated to:

window.criteo_q.push(
{ event: “setAccount”, account: xxxx },
{ event: “setHashedEmail”, email: “xxxx” },
{ event: “setSiteType”, type: “d” },
{ event: “viewBasket”, item: [object Object],[object Object] }
);

The strange thing is that I am using the same client property within an eCommerce tool and the list of objects is correclty being parsed by GA4.

I’m curious to know if this error is a red herring or not?

Cheers
Tom

Can you show your Custom HTML code?

Sure thing it looks like this:

<script type="text/javascript">
	window.criteo_q = window.criteo_q || [];
	window.criteo_q.push(
		{ event: "setAccount", account: xxxx },
		{ event: "setHashedEmail", email: "{{ client.md5email }}" },
		{ event: "setSiteType", type: "{{ client.layoutCode }}" },
		{ event: "viewBasket", item: [{{ client.products }}] }
	);
</script> 

This evaluated in the Zaraz Debugger to:

<script type="text/javascript"> 
		window.criteo_q = window.criteo_q || []; 
		window.criteo_q.push( 
			{ event: "setAccount", account: xxxx}, 
			{ event: "setHashedEmail", email: "xxxx" }, 
			{ event: "setSiteType", type: "d" }, 
			{ event: "viewBasket", item: [[object Object],[object Object],[object Object],[object Object]] } 
		); 
</script>

At the same time an Uncaught SyntaxError is thrown in the console:
image

Unfortunately including objects and array isn’t supported at the moment. If you’re an enterprise customer, reach out to us through your account executive and we can show you how to use a Worker to work around this. Otherwise, we’re working on bringing this feature to all paying users soon.