Google Analytics ecommerce data has to be sent along with a hit, like pageview or event. However, for some reason, the pageview hit inserted in a separate <script> tag (in _getGoogleAnalyticsTag()) is often sent before the ecommerce data is set, resulting in no checkout steps being sent.
Since checkout steps do not send an event hit type in the JS lib, we need to send a pageview hit right after setting the ecommerce data. We also set $js-state to 1 in the hookFooter for checkout pages so that there is no duplicate pageview sent to Google Analytics.
Google Analytics ecommerce data has to be sent along with a hit, like
pageview
or event. However, for some reason, thepageview
hit inserted in a separate<script>
tag (in_getGoogleAnalyticsTag()
) is often sent before the ecommerce data is set, resulting in no checkout steps being sent.Since checkout steps do not send an
event
hit type in the JS lib, we need to send apageview
hit right after setting the ecommerce data. We also set$js-state
to 1 in the hookFooter for checkout pages so that there is no duplicate pageview sent to Google Analytics.