function getclicky_admin_settings_form in Clicky - Web Analytics in Real Time 6
Same name and namespace in other branches
- 8 getclicky.admin.inc \getclicky_admin_settings_form()
- 7 getclicky.admin.inc \getclicky_admin_settings_form()
returns the admin form
1 string reference to 'getclicky_admin_settings_form'
- getclicky_menu in ./
getclicky.module - Implementation of hook_menu().
File
- ./
getclicky.admin.inc, line 17 - Administrative page callbacks for the getclicky module.
Code
function getclicky_admin_settings_form() {
$form = array();
$form['account'] = array(
'#type' => 'fieldset',
'#title' => t('GetClicky Account Settings'),
'#collapsible' => FALSE,
);
$form['account']['getclicky_site_id_number'] = array(
'#type' => 'textfield',
'#title' => t('Site ID'),
'#default_value' => variable_get('getclicky_site_id_number', ''),
'#size' => 15,
'#maxlength' => 20,
'#required' => TRUE,
// todo clear this a bit
// '#description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, <a href="@analytics">register your site with Google Analytics</a>, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. <a href="@webpropertyid">Find more information in the documentation</a>.', array('@analytics' => 'http://www.google.com/analytics/', '@webpropertyid' => 'http://code.google.com/apis/analytics/docs/concepts/gaConceptsAccounts.html#webProperty')),
'#description' => t('Example input: 130169<br>
This number is unique to every website you track via Clicky(a.k.a. GetClicky).<br>
- If you <b>do not</b> have an account with Clicky - you can obtain one from the <a href="@url1">GetClicky</a> website. (clicking on this link shows your support for my development of this module - especially if you decide to buy a Pro account with Clicky. Here is <a href="http://getclicky.com/#theotherguys">why</a> and here is <a href="http://getclicky.com/help/pricing">accounts comparison</a>)<br>
- If you <b>DO</b> have a Clicky account - you can find that number here:<br>
- anywhere you see a link like that <a href="@url2">http://getclicky.com/<b>130169</b></a> - take only the number - this is your Clicky site ID number.
- you can find this in your affiliate link (if you have many sites tracked by one Clicky user account - the affiliate link uses the 1st site\'s ID), <br>
- also in your tracking code and in your site prefs page ...
', array(
'@url1' => 'http://getclicky.com/130169',
'@url2' => 'http://getclicky.com/130169',
)),
);
$form['account']['getclicky_site_key_number'] = array(
'#type' => 'textfield',
'#title' => t('Site Key Number'),
'#default_value' => variable_get('getclicky_site_key_number', ''),
'#size' => 100,
'#maxlength' => 100,
'#required' => FALSE,
'#description' => t('Example input: 72543da7406597242<br>
This number is an API key used to display stats on the <a hre"">page</a>.'),
);
// Page specific visibility configurations.
$form['page_vis_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Page specific tracking settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$access = user_access('use PHP for tracking visibility');
$visibility = variable_get('googleanalytics_visibility', 0);
$pages = variable_get('googleanalytics_pages', GOOGLEANALYTICS_PAGES);
if ($visibility == 2 && !$access) {
$form['page_vis_settings'] = array();
$form['page_vis_settings']['visibility'] = array(
'#type' => 'value',
'#value' => 2,
);
$form['page_vis_settings']['pages'] = array(
'#type' => 'value',
'#value' => $pages,
);
}
else {
$options = array(
t('Add to every page except the listed pages.'),
t('Add to the listed pages only.'),
);
$description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
));
if ($access) {
$options[] = t('Add if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$description .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array(
'%php' => '<?php ?>',
));
}
$form['page_vis_settings']['googleanalytics_visibility'] = array(
'#type' => 'radios',
'#title' => t('Add tracking to specific pages'),
'#options' => $options,
'#default_value' => $visibility,
);
$form['page_vis_settings']['googleanalytics_pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => $pages,
'#description' => $description,
'#wysiwyg' => FALSE,
'#rows' => 10,
);
}
// Render the role overview.
$form['role_vis_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Role specific tracking settings'),
'#collapsible' => TRUE,
);
$form['role_vis_settings']['googleanalytics_visibility_roles'] = array(
'#type' => 'radios',
'#title' => t('Add tracking for specific roles'),
'#options' => array(
t('Add to the selected roles only'),
t('Add to every role except the selected ones'),
),
'#default_value' => variable_get('googleanalytics_visibility_roles', 0),
);
$roles = user_roles();
$role_options = array();
foreach ($roles as $rid => $name) {
$role_options[$rid] = $name;
}
$form['role_vis_settings']['googleanalytics_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Roles'),
'#default_value' => variable_get('googleanalytics_roles', array()),
'#options' => $role_options,
'#description' => t('If none of the roles are selected, all users will be tracked. If a user has any of the roles checked, that user will be tracked (or excluded, depending on the setting above).'),
);
// Standard tracking configurations.
$form['user_vis_settings'] = array(
'#type' => 'fieldset',
'#title' => t('User specific tracking settings'),
'#collapsible' => TRUE,
);
$form['user_vis_settings']['googleanalytics_custom'] = array(
'#type' => 'radios',
'#title' => t('Custom tracking settings'),
'#options' => array(
t('Users cannot control whether they are tracked or not.'),
t('Track users by default, but let individual users to opt out.'),
t('Do not track users by default, but let individual users to opt in.'),
),
'#description' => t('Allow individual users to customize the visibility of tracking in their account settings. Only users with %permission permission are allowed to set their own preference.', array(
'%permission' => t('opt-in or out of tracking'),
)),
'#default_value' => variable_get('googleanalytics_custom', 0),
);
// Render the role overview.
$result = db_query('SELECT * FROM {role} ORDER BY name');
$form['roles'] = array(
'#type' => 'fieldset',
'#title' => t('User Role Tracking'),
'#collapsible' => TRUE,
'#description' => t('Define what user roles should be tracked by Get Clicky. <strong>Note:</strong> Drupal Admin pages are never tracked.'),
);
$form['roles']['getclicky_track__user1'] = array(
'#type' => 'checkbox',
'#title' => t('Admin (user 1)'),
'#default_value' => variable_get('getclicky_track__user1', FALSE),
);
while ($role = db_fetch_object($result)) {
$form['roles']['getclicky_track_' . $role->rid] = array(
'#type' => 'checkbox',
'#title' => check_plain($role->name),
'#default_value' => variable_get('getclicky_track_' . $role->rid, FALSE),
);
}
$form['getclicky_banner_image'] = array(
'#type' => 'fieldset',
'#title' => t('GetClicky Banner Image'),
'#collapsible' => TRUE,
);
// todo present nice list of banner graphics
// todo implement hook_block with a banner
// todo the block can be changed in its settings
$form['getclicky_banner_image']['getclicky_show_banner_image'] = array(
'#type' => 'checkbox',
'#title' => t('Inject GetClicky Banner Image in html code\'s footer? (right before the closing body tag)'),
'#description' => t('Check this to show this in your site\'s footer automatically if you want visitors to click on your affiliate link.'),
'#default_value' => variable_get('getclicky_show_banner_image', FALSE),
);
$form['getclicky_banner_image']['getclicky_banner_image_html_code_for_copying'] = array(
'#type' => 'textarea',
'#title' => t('HTML Banner code (used in the block we provide)'),
'#description' => t('This code is used in the block we provide for you - go to <a href="/admin/build/block">/admin/build/block</a> to put it into a region.<br>
<b>See here - <a href="http://getclicky.com/user/affiliate">http://getclicky.com/user/affiliate</a> for more banner images. Paste from there into here, and the block here will auto-update. </b>
'),
'#default_value' => variable_get('getclicky_banner_image_html_code_for_copying', '<a title="Clicky Web Analytics" href="http://getclicky.com/' . variable_get('getclicky_site_id_number', '') . '"><img alt="Clicky Web Analytics" src="http://static.getclicky.com/media/links/badge.gif" border="0" /></a>'),
);
// Link specific configurations.
$form['linktracking'] = array(
'#type' => 'fieldset',
'#title' => t('Link tracking settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['linktracking']['googleanalytics_trackoutgoing'] = array(
'#type' => 'checkbox',
'#title' => t('Track outbound links'),
'#default_value' => variable_get('googleanalytics_trackoutgoing', 1),
'#description' => t('Enables tracking of clicks on outgoing links.'),
);
$form['linktracking']['googleanalytics_trackmailto'] = array(
'#type' => 'checkbox',
'#title' => t('Track mailto links'),
'#default_value' => variable_get('googleanalytics_trackmailto', 1),
'#description' => t('Enables tracking of clicks on mailto links.'),
);
$form['linktracking']['googleanalytics_trackfiles'] = array(
'#type' => 'checkbox',
'#title' => t('Track download links'),
'#default_value' => variable_get('googleanalytics_trackfiles', 1),
'#description' => t('Enables tracking of clicks on links to files based on the file extensions list below.'),
);
$form['linktracking']['googleanalytics_trackfiles_extensions'] = array(
'#type' => 'textfield',
'#title' => t('File extensions to track'),
'#default_value' => variable_get('googleanalytics_trackfiles_extensions', GOOGLEANALYTICS_TRACKFILES_EXTENSIONS),
'#description' => t('A pipe separated list of file extensions that should be tracked when clicked with regular expression support. Example: !extensions', array(
'!extensions' => GOOGLEANALYTICS_TRACKFILES_EXTENSIONS,
)),
'#maxlength' => 255,
);
// Privacy specific configurations.
$form['tracking']['privacy'] = array(
'#type' => 'fieldset',
'#title' => t('Privacy'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['tracking']['privacy']['googleanalytics_tracker_anonymizeip'] = array(
'#type' => 'checkbox',
'#title' => t('Anonymize visitors IP address'),
'#description' => t('Tell Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage. Note that this will slightly reduce the accuracy of geographic reporting. In some countries it is not allowed to collect personally identifying information for privacy reasons and this setting may help you to comply with the local laws.'),
'#default_value' => variable_get('googleanalytics_tracker_anonymizeip', 0),
);
$form['tracking']['privacy']['googleanalytics_privacy_donottrack'] = array(
'#type' => 'checkbox',
'#title' => t('Universal web tracking opt-out'),
'#description' => t('If enabled and your server receives the <a href="http://donottrack.us/">Do-Not-Track</a> header from the client browser, the Google Analytics module will not embed any tracking code into your site. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision. This feature is currently limited to logged in users and disabled page caching.'),
'#default_value' => variable_get('googleanalytics_privacy_donottrack', 1),
);
$form['segmentation'] = array(
'#type' => 'fieldset',
'#title' => t('User Segmentation'),
'#collapsible' => TRUE,
'#description' => t('If your users have profile fields completed, you can track your logged in users based on a defined profile field.'),
);
// "profile" module integration
if (!module_exists('profile')) {
$form['segmentation']['profile'] = array(
'#type' => 'markup',
'#value' => t('You need to activate the !profile to use this feature.', array(
'!profile' => l(t('Profile module'), 'admin/build/modules'),
)),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
}
else {
// Compile a list of fields to show.
$fields = unserialize(GETCLICKY_FIELDS_INIT);
$result = db_query('SELECT name, title, type, weight FROM {profile_fields} ORDER BY weight');
while ($record = db_fetch_object($result)) {
$fields[$record->name] = $record->title;
}
// $fields = Array ( [uid] => User ID (uid in mysql) [name] => Username (name) [roles] => User Roles (roles) )
$form['segmentation']['getclicky_segmentation'] = array(
'#type' => 'select',
'#title' => t('Track'),
'#description' => t('Selecting one or more values allows you to track users by profile values rather than simply an IP address. To select multiple items, hold down CTRL whilst selecting fields.'),
'#default_value' => variable_get('getclicky_segmentation', ''),
'#options' => $fields,
'#size' => 10,
'#multiple' => TRUE,
);
$default_mappings = unserialize(GETCLICKY_FIELDS_TO_CLICKY_DEFAULT_MAPPINGS);
foreach ($fields as $key => $value) {
$form['segmentation']['getclicky_segmentation_mapping_' . $key] = array(
'#type' => 'textfield',
'#title' => t('clicky JS var name for drupal profile field named ') . $key . " ({$value})",
'#default_value' => variable_get('getclicky_segmentation_mapping_' . $key, !empty($default_mappings[$key]) ? $default_mappings[$key] : $key),
'#description' => t('Give the getclicky varname you want to corespond to this drupal field.'),
);
}
}
$form['getclicky_trackfiles'] = array(
'#type' => 'textfield',
'#title' => t('File Extensions To Track'),
'#default_value' => variable_get('getclicky_trackfiles', 'pdf|zip|mp3'),
'#description' => t('A pipe seperated list of file extensions that should be tracked when clicked. Example !extensions', array(
'!extensions' => 'pdf|zip|mp3',
)),
);
$form['getclicky_secure_pages_tracking'] = array(
'#type' => 'fieldset',
'#title' => t('Secure Pages'),
'#collapsible' => TRUE,
'#description' => t(''),
);
$form['getclicky_secure_pages_tracking']['getclicky_secure_pages_tracking_option'] = array(
'#type' => 'radios',
'#title' => t('Choose how to track secure pages (https:// aka SSL pages ) (If you do not use SSL in your site - this setting does not matter.)'),
'#default_value' => variable_get('getclicky_secure_pages_tracking_option', 0),
'#options' => array(
t('When onto a https page - do not inject any js code. I do not have a Pro account and/or I do not want to track https pages.'),
t('When onto a https page - use the js code for secure pages. I have a Pro account.'),
t('When onto a https page - use the js code for normal http pages. I do not have a Pro account and I do not mind the mixed-content-warning.'),
),
);
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('You can add custom Get Clicky code here.'),
);
$form['advanced']['getclicky_codesnippet'] = array(
'#type' => 'textarea',
'#title' => t('JavaScript Code'),
'#default_value' => variable_get('getclicky_codesnippet', ''),
'#rows' => 15,
'#wysiwyg' => FALSE,
'#description' => t('Paste <a href="@snippets">custom code snippets here</a>. These will be added to every page that Get Clicky appears on.', array(
'@snippets' => 'http://drupal.org/node/39282',
)),
);
// Advanced feature configurations.
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['advanced']['googleanalytics_cache'] = array(
'#type' => 'checkbox',
'#title' => t('Locally cache tracking code file'),
'#description' => t("If checked, the tracking code file is retrieved from Google Analytics and cached locally. It is updated daily from Google's servers to ensure updates to tracking code are reflected in the local copy. Do not activate this until after Google Analytics has confirmed that site tracking is working!"),
'#default_value' => variable_get('googleanalytics_cache', 0),
);
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
$form['advanced']['googleanalytics_cache']['#disabled'] = TRUE;
$form['advanced']['googleanalytics_cache']['#description'] .= ' ' . t('<a href="@url">Public file transfers</a> must be enabled to allow local caching.', array(
'@url' => url('admin/settings/file-system', array(
'query' => drupal_get_destination(),
)),
));
}
// Allow for tracking of the originating node when viewing translation sets.
if (module_exists('translation')) {
$form['advanced']['googleanalytics_translation_set'] = array(
'#type' => 'checkbox',
'#title' => t('Track translation sets as one unit'),
'#description' => t('When a node is part of a translation set, record statistics for the originating node instead. This allows for a translation set to be treated as a single unit.'),
'#default_value' => variable_get('googleanalytics_translation_set', 0),
);
}
$site_search_dependencies = '<div class="admin-dependencies">';
$site_search_dependencies .= t('Depends on: !dependencies', array(
'!dependencies' => module_exists('search') ? t('@module (<span class="admin-enabled">enabled</span>)', array(
'@module' => 'Search',
)) : t('@module (<span class="admin-disabled">disabled</span>)', array(
'@module' => 'Search',
)),
));
$site_search_dependencies .= '</div>';
// Google already have many translations, if not - they display a note to change the language.
global $language;
$form['advanced']['googleanalytics_site_search'] = array(
'#type' => 'checkbox',
'#title' => t('Track internal search'),
'#description' => t('If checked, internal search keywords are tracked. You must configure your Google account to use the internal query parameter <strong>search</strong>. For more information see <a href="@url">How do I set up Site Search for my profile</a>.', array(
'@url' => 'http://www.google.com/support/analytics/bin/answer.py?hl=' . $language->language . '&answer=75817',
)) . $site_search_dependencies,
'#default_value' => variable_get('googleanalytics_site_search', FALSE),
'#disabled' => module_exists('search') ? FALSE : TRUE,
);
$form['advanced']['googleanalytics_trackadsense'] = array(
'#type' => 'checkbox',
'#title' => t('Track AdSense ads'),
'#description' => t('If checked, your AdSense ads will be tracked in your Google Analytics account.'),
'#default_value' => variable_get('googleanalytics_trackadsense', FALSE),
);
$form['advanced']['codesnippet'] = array(
'#type' => 'fieldset',
'#title' => t('Custom JavaScript code'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('You can add custom Google Analytics <a href="@snippets">code snippets</a> here. These will be added to every page that Google Analytics appears on. Before you add custom code to the below textarea\'s you should read <a href="@ga_concepts_overview">Google Analytics Tracking Code - Functional Overview</a> and the <a href="@ga_js_api">Google Analytics Tracking API</a> documentation. <strong>Do not include the <script> tags</strong>, and always end your code with a semicolon (;).', array(
'@snippets' => 'http://drupal.org/node/248699',
'@ga_concepts_overview' => 'http://code.google.com/apis/analytics/docs/gaConceptsOverview.html',
'@ga_js_api' => 'http://code.google.com/apis/analytics/docs/gaJSApi.html',
)),
);
$form['advanced']['codesnippet']['googleanalytics_codesnippet_before'] = array(
'#type' => 'textarea',
'#title' => t('Code snippet (before)'),
'#default_value' => variable_get('googleanalytics_codesnippet_before', ''),
'#rows' => 5,
'#wysiwyg' => FALSE,
'#description' => t("Code in this textarea will be added <strong>before</strong> _gaq.push(['_trackPageview'])."),
);
$form['advanced']['codesnippet']['googleanalytics_codesnippet_after'] = array(
'#type' => 'textarea',
'#title' => t('Code snippet (after)'),
'#default_value' => variable_get('googleanalytics_codesnippet_after', ''),
'#rows' => 5,
'#wysiwyg' => FALSE,
'#description' => t("Code in this textarea will be added <strong>after</strong> _gaq.push(['_trackPageview']). This is useful if you'd like to track a site in two accounts."),
);
/* hook_footer() is not able to add code to head. Upgrade to D7 required.
$form['advanced']['googleanalytics_js_scope'] = array(
'#type' => 'select',
'#title' => t('JavaScript scope'),
'#description' => t("Google recommends adding the external JavaScript files to header for performance reasons."),
'#options' => array(
'footer' => t('Footer'),
'header' => t('Header'),
),
'#default_value' => variable_get('googleanalytics_js_scope', 'header'),
); */
return system_settings_form($form);
}