Closed pierreavizou closed 8 years ago
It's probably related to a previous request, cause it was working before. I'm not sure we should add pageview outside of the main scope, cause we had a lot of bug with pageview sent 2 times. I'll look for the request that broke this.
Thanks for the feedback.
Actually I believe there is no risk to send pageview twice when we set $js_state to 1 correctly, because this prevents the ga('send', 'pageview')
from being injected into the template by the _runJs()
function.
It's great if you can find a previous PR that broke this and then revert it, otherwise my PR is here to help. :)
Could it be linked to #71 ?
Yes I think it is, because prior to #71, ecommece data configuration and pageview hit sending were done in the same <script>
tag, which this PR has divided into two tags, which causes the pageview hit to be sent before ecommerce data configuration.
It's not possible to affirm this with certainty without testing (G.A. can be tricky sometimes), but my guess is that #71 is indeed responsible for introducing the bug.
So either we revert and we will have false positive about code not detected, either the steps does not work.
Seems like neither is truly a good option :/
I think that the modification in my PR solves both issues.
It does not seem to be a problem to send pageview hits within the JS Lib, because thanks to the $js_state variable, we can prevent it from being sent a second time from the _runJs()
function. Actually from looking at it, it seems that it's for this kind of use cases that this variable was implemented. That's why I felt it would be fine to use it in order to solve this issue.
Hi @pierreavizou,
Thanks, your PR has just been merged and a new version will be released for tomorrow.
Best regards
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.