@@ -14,22 +14,25 @@ function init() {
14
14
$ ( document ) . on ( 'click' , "[data-toggle='rst-current-version']" , function ( ) {
15
15
var flyout_state = $ ( "[data-toggle='rst-versions']" ) . hasClass ( 'shift-up' ) ? 'was_open' : 'was_closed' ;
16
16
17
- // This needs to handle old style legacy analytics for previously built docs
18
- // as well as the newer universal analytics and Google Site Tag
19
- if ( typeof gtag !== 'undefined' ) {
20
- // https://developers.google.com/analytics/devguides/collection/gtagjs/events
21
- gtag ( 'event' , 'Click' , {
22
- 'event_category' : 'Flyout' ,
23
- 'event_label' : flyout_state ,
24
- 'send_to' : 'rtfd'
25
- } ) ;
26
- } else if ( typeof ga !== 'undefined' ) {
27
- ga ( 'rtfd.send' , 'event' , 'Flyout' , 'Click' , flyout_state ) ;
28
- } else if ( typeof _gaq !== 'undefined' ) {
29
- _gaq . push (
30
- [ 'rtfd._setAccount' , 'UA-17997319-1' ] ,
31
- [ 'rtfd._trackEvent' , 'Flyout' , 'Click' , flyout_state ]
32
- ) ;
17
+ // Only report back if analytics is enabled
18
+ if ( typeof READTHEDOCS_DATA !== 'undefined' && READTHEDOCS_DATA . global_analytics_code ) {
19
+ // This needs to handle old style legacy analytics for previously built docs
20
+ // as well as the newer universal analytics and Google Site Tag
21
+ if ( typeof gtag !== 'undefined' ) {
22
+ // https://developers.google.com/analytics/devguides/collection/gtagjs/events
23
+ gtag ( 'event' , 'Click' , {
24
+ 'event_category' : 'Flyout' ,
25
+ 'event_label' : flyout_state ,
26
+ 'send_to' : 'rtfd'
27
+ } ) ;
28
+ } else if ( typeof ga !== 'undefined' ) {
29
+ ga ( 'rtfd.send' , 'event' , 'Flyout' , 'Click' , flyout_state ) ;
30
+ } else if ( typeof _gaq !== 'undefined' ) {
31
+ _gaq . push (
32
+ [ 'rtfd._setAccount' , 'UA-17997319-1' ] ,
33
+ [ 'rtfd._trackEvent' , 'Flyout' , 'Click' , flyout_state ]
34
+ ) ;
35
+ }
33
36
}
34
37
} ) ;
35
38
0 commit comments