Closed pixelmachine closed 7 months ago
Yep, looks right to me. The way you're debugging things is likely fine; you can also use XDebug on the PHP side of things to make it easier.
And then open up your Google Analytics backend and see what is sent there.
I fixed the typo in the docs, thanks.
Thanks @khalwat
It seems Google doesn't show commerce data submissions on new sites until a certain amount has been submitted. So in this case and another previous case it wasn't possible for me to see what data was sent until the site was live and the data was flowing.
Makes sense -- I wish I knew of a better way. Perhaps they have some kind of sandbox mode that works more immediately for testing?
Not sure, if I find anything I'll let you know!
@khalwat re. the typo I mentioned. I just realised it's still wrong:
{% do instantAnalytics.viewItemEvent(viewItemEvent) %}
Should be
{% do instantAnalytics.addEvent(viewItemEvent) %}
Right?
haha -- fail. Yep, you're right. Fixed it for real this time.
Question
The documentation has an example of manually creating and sending a view_item event. However the example doesn't show how to add the nested items that are needed. Looking at the code and GA4 MP docs this is what I've come up with:
Does this look correct?
Additionally, what's the best way to debug? I can
dump()
the objects created but I wondered if there was a better way to see what's happening.Finally there's a small typo in the docs. After the Event Reference table you have
{% do instantAnalytics.viewItemEvent(searchEvent) %}
but you should be passing inviewItemEvent
notsearchEvent
.