alphagov / govuk_frontend_toolkit

❗️GOV.UK Frontend Toolkit is deprecated, and will only receive major bug fixes and security patches.
MIT License
403 stars 107 forks source link

Only make GOV.UK analytics call when GA is ready #404

Closed boffbowsh closed 7 years ago

boffbowsh commented 7 years ago

We want to send the gaClientId with our GOV.UK analytics payload, but due to asynchronous loading we may not have actually fetched it from the GA library by the time sendToTracker is called.

If GA is enabled on this page, we now wrap the call to sendData in the “ga ready” callback function and make sure we set the clientId first.