templates
3 years ago
ga-accounts-selector.php
4 years ago
ga-auth-button.php
4 years ago
ga-code.php
4 years ago
ga-dashboard-widget.php
4 years ago
ga-debug-modal.php
4 years ago
ga-ga4-settings.php
3 years ago
ga-googleanalytics-loader.php
4 years ago
ga-notice.php
3 years ago
ga-oauth-notice.php
4 years ago
ga-wp-notice.php
4 years ago
page.php
3 years ago
statistics.php
3 years ago
stats.php
3 years ago
trending.php
4 years ago
ga-ga4-settings.php
256 lines
| 1 | <?php |
| 2 | $ga4_exclude_roles = true === is_array($ga4_exclude_roles) ? $ga4_exclude_roles : []; |
| 3 | ?> |
| 4 | <script type="text/javascript"> |
| 5 | const GA_NONCE = '<?php echo esc_js( $ga_nonce ); ?>'; |
| 6 | const GA_NONCE_FIELD = 'ga4-setup'; |
| 7 | </script> |
| 8 | <div class="settings-wrap setup-wrap<?php echo true === $setup_done ? ' hide' : ''; ?>"> |
| 9 | <?php $auth_info = Ga_Admin::getGa4AuthInfo(); ?> |
| 10 | <div class="ga-step ga-step-1<?php echo false === $has_code && false === $has_property ? ' engage' : ''; ?>"> |
| 11 | <div class="ga-steps"> |
| 12 | 1 of 3 |
| 13 | <div class="ga-dots"><span class="dark-green">•</span> • •</div> |
| 14 | </div> |
| 15 | <h2>Setup Google Authentication</h2> |
| 16 | <p>Use our configuration wizard to properly setup Google Analytics with Wordpress (with just a few clicks).</p> |
| 17 | <a id="google-auth-link" href="<?php echo esc_url($auth_info['auth_url']); ?>"> |
| 18 | <img src="<?php echo plugins_url() . '/googleanalytics/assets/images/Google-logo.svg'; ?>" alt="Google Logo">Sign in with Google |
| 19 | </a> |
| 20 | </div> |
| 21 | <div class="ga-step ga-step-2<?php echo false !== $has_code && false === $has_property ? ' engage' : ''; ?>"> |
| 22 | <div class="ga-steps"> |
| 23 | 2 of 3 |
| 24 | <div class="ga-dots">• <span class="dark-green">•</span> •</div> |
| 25 | </div> |
| 26 | <h2>Select Account Property</h2> |
| 27 | <p>Choose the view you want to use for your reports.</p> |
| 28 | <label for="ga4-property"> |
| 29 | <select id="ga4-property"> |
| 30 | <option>Choose Property</option> |
| 31 | <?php foreach($auth_info['properties'] as $account => $properties) : |
| 32 | if (false === empty($properties)) : ?> |
| 33 | <option disabled><?php echo esc_html($account); ?>:</option> |
| 34 | <?php foreach ($properties as $property) : ?> |
| 35 | <option value="<?php echo esc_attr($property['name'] ); ?>"><?php echo esc_html($property['displayName'] ); ?></option> |
| 36 | <?php endforeach; endif; endforeach;?> |
| 37 | </select> |
| 38 | </label> |
| 39 | <a id="to-step-3">Next</a> |
| 40 | </div> |
| 41 | <div class="ga-step ga-step-3<?php echo false === $setup_done && false !== $has_code && false !== $has_property ? ' engage' : ''; ?>"> |
| 42 | <div class="ga-steps"> |
| 43 | 3 of 3 |
| 44 | <div class="ga-dots">• • <span class="dark-green">•</span></div> |
| 45 | </div> |
| 46 | <div class="extra-settings"> |
| 47 | <h2>Settings</h2> |
| 48 | <div class="ga-row"> |
| 49 | <div class="ua-dual-settings"> |
| 50 | <div class="ga-ua-col"> |
| 51 | <h2>If using Google Optimize, enter optimize code here</h2> |
| 52 | <label> |
| 53 | <input id="ga4-google-optimize" type="text" placeholder="GMT-XXXXXX" value=""> |
| 54 | </label> |
| 55 | |
| 56 | <h2>Exclude Tracking for Roles</h2> |
| 57 | <div class="ga-exclude-roles"> |
| 58 | <div class="switch"> |
| 59 | <label class="item"> |
| 60 | <input type="checkbox" value="administrator"> |
| 61 | <span class="lever"></span> |
| 62 | Administrator |
| 63 | </label> |
| 64 | </div> |
| 65 | <div class="switch"> |
| 66 | <label class="item"> |
| 67 | <input type="checkbox" value="contributor"> |
| 68 | <span class="lever"></span> |
| 69 | Contributor |
| 70 | </label> |
| 71 | </div> |
| 72 | <div class="switch"> |
| 73 | <label class="item"> |
| 74 | <input type="checkbox" value="editor"> |
| 75 | <span class="lever"></span> |
| 76 | Editor |
| 77 | </label> |
| 78 | </div> |
| 79 | <div class="switch"> |
| 80 | <label class="item"> |
| 81 | <input type="checkbox" value="subscriber"> |
| 82 | <span class="lever"></span> |
| 83 | Subscriber |
| 84 | </label> |
| 85 | </div> |
| 86 | <div class="switch"> |
| 87 | <label class="item"> |
| 88 | <input type="checkbox" value="author"> |
| 89 | <span class="lever"></span> |
| 90 | Author |
| 91 | </label> |
| 92 | </div> |
| 93 | </div> |
| 94 | </div> |
| 95 | <div class="ga-ua-col"> |
| 96 | <div class="switch"> |
| 97 | <label class="item"> |
| 98 | Enable Demographics |
| 99 | <input id="ga4-enable-demo" type="checkbox"> |
| 100 | <span class="lever"></span> |
| 101 | </label> |
| 102 | </div> |
| 103 | <div class="switch"> |
| 104 | <label class="item"> |
| 105 | Enable IP Anonymization |
| 106 | <input type="checkbox" id="ga4-enable-ip-anon"> |
| 107 | <span class="lever"></span> |
| 108 | </label> |
| 109 | </div> |
| 110 | <div class="switch"> |
| 111 | <label class="item"> |
| 112 | Enable GDPR Consent Management Tool |
| 113 | <input type="checkbox" id="ga4-enable-gdpr"> |
| 114 | <span class="lever"></span> |
| 115 | </label> |
| 116 | </div> |
| 117 | </div> |
| 118 | </div> |
| 119 | </div> |
| 120 | <a id="complete-ga4-setup" class="green-button" href="<?php echo get_admin_url(); ?>admin.php?page=googleanalytics">Complete and go to dashboard</a> |
| 121 | </div> |
| 122 | </div> |
| 123 | </div> |
| 124 | |
| 125 | <?php if (true === $setup_done) : ?> |
| 126 | <div style="margin-top: 0;<?php echo true === $setup_done ? '' : ' display: none;'; ?>" class="ga4_container ga_container"> |
| 127 | <?php if ( false === empty( $data['error_message'] ) ) : ?> |
| 128 | <?php echo wp_kses_post( $data['error_message'] ); ?> |
| 129 | <?php endif; ?> |
| 130 | <h1>Google Analytics 4 - Settings</h1> |
| 131 | <form id="ga4_form" method="post" action="options.php"> |
| 132 | <?php settings_fields( 'googleanalyticsga4' ); ?> |
| 133 | <table class="form-table"> |
| 134 | <tr> |
| 135 | <?php if ( false === empty( $data['popup_url'] ) ) : ?> |
| 136 | <th scope="row"> |
| 137 | <label class="<?php echo esc_attr( false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip"' : '' ); ?>"> |
| 138 | <?php esc_html_e( 'Google Profile' ); ?>: |
| 139 | <span class="ga-tooltiptext ga-tt-abs"><?php echo esc_html( $tooltip ); ?></span> |
| 140 | </label> |
| 141 | </th> |
| 142 | <?php endif; ?> |
| 143 | </tr> |
| 144 | <?php if ( false === empty( $auth_info['properties'] ) ) : ?> |
| 145 | <tr> |
| 146 | <td> |
| 147 | <select id="ga_account_selector" name="googleanalytics-ga4-property"> |
| 148 | <option>Please select your Google Analytics account:</option> |
| 149 | <?php foreach($auth_info['properties'] as $account => $properties) : |
| 150 | if (false === empty($properties)) : ?> |
| 151 | <option disabled><?php echo esc_html($account); ?>:</option> |
| 152 | <?php foreach ($properties as $property) : ?> |
| 153 | <option value="<?php echo esc_attr($property['name'] ); ?>" <?php echo $property['name'] === $has_property ? 'selected' : ''; ?>> |
| 154 | <?php echo esc_html($property['displayName'] ); ?> |
| 155 | </option> |
| 156 | <?php endforeach; endif; endforeach;?> |
| 157 | </select> |
| 158 | </td> |
| 159 | <td> |
| 160 | <button id="ga4_sign_out" class="button-secondary" type="button"> |
| 161 | <?php esc_html_e( 'Sign out', 'googleanalytics' ); ?> |
| 162 | </button> |
| 163 | </td> |
| 164 | </tr> |
| 165 | <?php endif; ?> |
| 166 | <tr id="ga_roles_wrapper"> |
| 167 | <th scope="row"> |
| 168 | <label class="<?php echo esc_attr( false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip' : '' ); ?>"> |
| 169 | <?php esc_html_e( 'Exclude Tracking for Roles' ); ?> |
| 170 | : |
| 171 | <span class="ga-tooltiptext ga-tt-abs"><?php echo esc_html( $tooltip ); ?></span> |
| 172 | </label> |
| 173 | </th> |
| 174 | </tr> |
| 175 | <tr> |
| 176 | <td> |
| 177 | <?php |
| 178 | if ( false === empty( $data['roles'] ) && true === is_array($ga4_exclude_roles)) { |
| 179 | $roles = $data['roles']; |
| 180 | foreach ( $roles as $role_item ) { |
| 181 | $role_id = true === isset($role_item['id']) ? $role_item['id'] : ''; |
| 182 | $role_name = true === isset($role_item['name']) ? $role_item['name'] : ''; |
| 183 | ?> |
| 184 | <div class="checkbox"> |
| 185 | <label class="ga_checkbox_label <?php echo esc_attr(false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip' : ''); ?>" |
| 186 | for="checkbox_<?php echo esc_attr( $role_id ); ?>"> |
| 187 | <input id="checkbox_<?php echo esc_attr( $role_id ); ?>" type="checkbox" |
| 188 | <?php echo disabled(false === Ga_Helper::are_features_enabled()); ?> |
| 189 | name="googleanalytics-ga4-exclude-roles[<?php echo esc_attr(str_replace('role-id-', '', $role_id)); ?>]" |
| 190 | id="<?php echo esc_attr( $role_id ); ?>" |
| 191 | <?php echo esc_attr( ( true === in_array(str_replace('role-id-', '', $role_id), array_keys($ga4_exclude_roles), true) ? 'checked="checked"' : '' ) ); ?> /> |
| 192 | <?php echo esc_html( $role_name ); ?> |
| 193 | <span class="ga-tooltiptext"><?php echo esc_html( $tooltip ); ?></span> |
| 194 | </label> |
| 195 | </div> |
| 196 | <?php |
| 197 | } |
| 198 | } |
| 199 | ?> |
| 200 | </td> |
| 201 | </tr> |
| 202 | <tr> |
| 203 | <th scope="row"><?php esc_html_e( 'Enable IP Anonymization' ); ?>:</th> |
| 204 | </tr> |
| 205 | <tr> |
| 206 | <td> |
| 207 | <label class="ga-switch <?php echo esc_attr(false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip' : ''); ?>"> |
| 208 | <?php if ( true === Ga_Helper::are_features_enabled() ) : ?> |
| 209 | <input id="ga-anonymization" name="googleanalytics-ga4-ip-anon" |
| 210 | type="checkbox" <?php echo checked( $ga4_ip, 'on' ); ?>> |
| 211 | |
| 212 | <div id="ga-slider" class="ga-slider round"></div> |
| 213 | <?php else : ?> |
| 214 | <input id="ga-anonymization" name="googleanalytics-ga4-ip-anon" |
| 215 | type="checkbox" disabled="disabled"> |
| 216 | |
| 217 | <div id="ga-slider" class="ga-slider round"></div> |
| 218 | <span class="ga-tooltiptext ga-tt-abs"><?php echo esc_html( $tooltip ); ?></span> |
| 219 | <?php endif; ?> |
| 220 | </label> |
| 221 | </td> |
| 222 | </tr> |
| 223 | <tr> |
| 224 | <td> |
| 225 | <input name="googleanalytics-ga4-demo" value="<?php echo esc_attr($ga4_demo); ?>" type="hidden"> |
| 226 | </td> |
| 227 | </tr> |
| 228 | <tr> |
| 229 | <th scope="row"><?php esc_html_e( 'If using Google Optimize, enter optimize code here' ); ?>:</th> |
| 230 | </tr> |
| 231 | <tr> |
| 232 | <td> |
| 233 | <label class="ga-text <?php echo esc_attr( false === Ga_Helper::are_features_enabled() ? 'label-grey ga-tooltip' : '' ); ?>"> |
| 234 | <?php if ( true === Ga_Helper::are_features_enabled() ) : ?> |
| 235 | <input id="ga-optimize" name="googleanalytics-ga4-optimize" |
| 236 | type="text" placeholder="GTM-XXXXXX" |
| 237 | value="<?php echo esc_attr( $ga4_optimize ); ?>"> |
| 238 | <?php else : ?> |
| 239 | <input id="ga-optimize" name="googleanalytics-ga4-optimize" |
| 240 | type="text" placeholder="GTM-XXXXXX" |
| 241 | value="<?php echo esc_attr( $ga4_optimize ); ?>" readonly> |
| 242 | <span class="ga-tooltiptext ga-tt-abs"><?php echo esc_html( $tooltip ); ?></span> |
| 243 | <?php endif; ?> |
| 244 | </label> |
| 245 | </td> |
| 246 | </tr> |
| 247 | <?php require $plugin_dir . 'templates/gdpr.php'; ?> |
| 248 | </table> |
| 249 | |
| 250 | <p class="submit"> |
| 251 | <input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes' ); ?>"/> |
| 252 | </p> |
| 253 | </form> |
| 254 | </div> |
| 255 | <?php endif; ?> |
| 256 |