After staring at the code for two hours, then getting good debug data, I figured the bug: if a page view is tracked at the same second as an ecommerce order, this pageview request may erase the visitEcommerceStatus flag.
Explanation:
- the ecommerce order request is received
- at same time the pageview for the checkout page is tracked.
This page view "reads" first the visit (which does not yet have "visitEcommerceStatus == ordered")
1b) the ecommerce is recorded and "visitEcommerceStatus == ordered" is set
2b) the pageview is recorded and "visitEcommerceStatus == none"
After staring at the code for two hours, then getting good debug data, I figured the bug: if a page view is tracked at the same second as an ecommerce order, this pageview request may erase the visitEcommerceStatus flag.
Explanation:
This page view "reads" first the visit (which does not yet have "visitEcommerceStatus == ordered")
1b) the ecommerce is recorded and "visitEcommerceStatus == ordered" is set
2b) the pageview is recorded and "visitEcommerceStatus == none"