Title: Errors if analytics lib is not loaded
Last modified: August 18, 2019

---

# Errors if analytics lib is not loaded

 *  [florianbepunkt](https://wordpress.org/support/users/florianbepunkt/)
 * (@florianbepunkt)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/errors-if-analytics-lib-is-not-loaded/)
 * We are using this plugin in conjunction with Borlabs Cookie in order stay GDPR
   compliant. We have an opt-in solution, which ensures, that Google Analytics is
   only loaded if the user agreed to being tracked.
 * However: If the user has not given consent and the google analytics lib is not
   loaded, your plugin throws an error that gtag function is undefined.
 * Would it be possible to safeguard these methods or more in general: That your
   plugin only runs, if an active Google Analytics integration was found?
 * GDPR court decisions move into the direction that opt-in is mandatory for Google
   Analytics/Tracking so I assume this will affect all European users of the plugin.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [dhyeychandani](https://wordpress.org/support/users/dhyeychandani/)
 * (@dhyeychandani)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/errors-if-analytics-lib-is-not-loaded/#post-11844065)
 * Hey,
 * Our plugin uses latest GA tracking gtag.js. While activating our plugin did you
   activate “Enable global site tracking”. If not, enable it and this will solve
   your concern.
 * Also this issue is not because of conflict between any other plugin.
 * Hope this helps.
 * Regards,
 *  Thread Starter [florianbepunkt](https://wordpress.org/support/users/florianbepunkt/)
 * (@florianbepunkt)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/errors-if-analytics-lib-is-not-loaded/#post-11844155)
 * Sorry, I was not clear enough. This is not what this was about.
 * We use a third-party-consent management plugin (Borlabs Cookie) that implements
   gtag.js
 * There are two scenarios:
 * (1) User gives consent to being tracked -> gtag.js is loaded
    (2) User gives 
   no consent to being tracked -> gtag.js is NOT loaded
 * We use your plugin only for the enhanced ecommerce functionality.
 * Problem: Your plugin throws errors if gtag.js is not loaded.
    Suggestion: Your
   plugin should check if gtag.js is loaded before executing your js
 * All current consent/opt-in solutions for GA work the same: They only load gtag.
   js if the user has agreed to it.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Errors if analytics lib is not loaded’ is closed to new replies.

 * ![](https://ps.w.org/enhanced-e-commerce-for-woocommerce-store/assets/icon-256x256.
   gif?rev=2708061)
 * [Conversios: Google Analytics (GA4), Google Ads, Conversion and Analytics Tracking for Multi-Channels](https://wordpress.org/plugins/enhanced-e-commerce-for-woocommerce-store/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/enhanced-e-commerce-for-woocommerce-store/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/enhanced-e-commerce-for-woocommerce-store/)
 * [Active Topics](https://wordpress.org/support/plugin/enhanced-e-commerce-for-woocommerce-store/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/enhanced-e-commerce-for-woocommerce-store/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/enhanced-e-commerce-for-woocommerce-store/reviews/)

 * 2 replies
 * 0 participants
 * Last reply from: [florianbepunkt](https://wordpress.org/support/users/florianbepunkt/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/errors-if-analytics-lib-is-not-loaded/#post-11844155)
 * Status: not resolved