/** * edit_options() * * @return void **/ static function edit_options() { $options = google_analytics::get_options(); if (empty($options['uacct'])) { $options['uacct'] = __('Your Account ID', 'google-analytics'); } echo '<div class="wrap">' . "\n" . '<form method="post" action="">' . "\n"; wp_nonce_field('google_analytics'); echo '<h2>' . __('Google Analytics Settings', 'google-analytics') . '</h2>' . "\n"; echo '<h3>' . __('Google Analytics ID', 'google-analytics') . '</h3>' . "\n"; echo '<table class="form-table">' . "\n"; echo '<tr valign="top">' . "\n" . '<th scope="row">' . __('Universal Analytics', 'google-analytics') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="universal_analytics"' . checked((bool) $options['universal_analytics'], true, false) . ' />' . ' ' . __('Track site using the new Universal Analytics tracking code (analytics.js)', 'google-analytics') . '</label>' . '<br />' . "\n" . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr valign="top">' . '<th scope="row">' . __('GA Script', 'google-analytics') . '</th>' . '<td>' . '<p>' . __('Paste the User ID from the <b>analytics.js</b> or <b>ga.js</b> script from <a href="http://www.google.com/analytics/" target="_blank" >Google Analytics</a> into the following textarea (<a href="https://support.google.com/analytics/answer/1008080?hl=en" target="_blank">where do I find it?</a>):', 'google-analytics') . '</p>' . "\n" . '<input type="text" name="ga_script"' . ' class="widefat code"' . ' value="' . esc_attr($options['uacct']) . '"' . ' />' . '<p>' . __("<i>If using the new Universal Analytics code (analytics.js) then in <code>ga('create', 'UA-123456-1', 'example.com');</code>, your ID is <code>UA-123456-1</code>.</i>", 'google-analytics') . '</p>' . '<p>' . __('<i>If using the classic Google Analytics code (ga.js) then in <code>var pageTracker = _gat._getTracker("UA-123456-1");</code>, your ID is <code>UA-123456-1</code>.</i>', 'google-analytics') . '</p>' . '</td>' . '</tr>'; echo '<tr>' . "\n" . '<th scope="row">' . __('Track Subdomains', 'google-analytics') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="subdomains"' . checked((bool) $options['subdomains'], true, false) . ' />' . ' ' . __('Track all subdomains in a single report - i.e. www.example.com, forums.example.com, store.example.com', 'google-analytics') . '</label>' . '<br />' . "\n" . '<p>' . __('<i><b>Note</b>: If you have WordPress and Semiologic installed on subdomains, you would use the same Google Analytics User ID for all subdomains and set this checkbox. If you wish to have each subdomain tracked as a different site, leave unchecked.</i>', 'google-analytics') . '</p>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Enable Display Tracking', 'google-analytics') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="displayTracking"' . checked((bool) $options['displayTracking'], true, false) . ' />' . ' ' . __('Enable Display Advertising Features in Google Analytics, such as Remarketing, Demographics and Interest Reporting.', 'google-analytics') . '</label>' . '<br />' . "\n" . '<p>' . __('<i><b>Note</b>: See <a href="https://support.google.com/analytics/answer/3450482" target="_blank">Learn more about Display Advertising Features in Google Analytics</a> for more information on this feature.</i>', 'google-analytics') . '</p>' . '</td>' . "\n" . '</tr>' . "\n"; echo "</table>\n"; echo '<div class="submit">' . '<input type="submit"' . ' value="' . esc_attr(__('Save Changes', 'google-analytics')) . '"' . " />" . "</div>\n"; echo '</form>' . "\n"; google_analytics_admin::crash_course(); echo '</div>' . "\n"; }
/** * get_options() * * @return array $options **/ static function get_options() { static $o; if (!is_admin() && isset($o)) { return $o; } $o = get_option('google_analytics'); if ($o === false || !is_array($o) || !isset($o['subdomains']) || !isset($o['universal_analytics'])) { $o = google_analytics::init_options(); } return $o; }