SZGoogleAdminAnalytics

The SZ - Google SZGoogleAdminAnalytics class.

Defined (1)

The class is defined in the following location(s).

/admin/classes/SZGoogleAdminAnalytics.php  
  1. class SZGoogleAdminAnalytics extends SZGoogleAdmin 
  2. /** 
  3. * Definition the constructor function, which is called 
  4. * at the time of the creation of an instance of this class 
  5. */ 
  6.  
  7. function __construct() 
  8. // Checking if I have to insert the tracking code 
  9. // for google analytics in wordpress admin panel  
  10.  
  11. $SZ_ANALYTICS_OBJECT_ADMIN = new SZGoogleModuleAnalytics(); 
  12. $SZ_ANALYTICS_OPTION_ADMIN = $SZ_ANALYTICS_OBJECT_ADMIN->getOptions(); 
  13.  
  14. // If you are the admin panel I need to check the activation 
  15. // of the option to enable the module on administration 
  16.  
  17. if (is_admin() and $SZ_ANALYTICS_OPTION_ADMIN['ga_enable_admin'] == '1')  
  18. if ($SZ_ANALYTICS_OPTION_ADMIN['ga_position'] == 'H')  
  19. add_action('admin_head', array(new SZGoogleActionAnalytics($this), 'action')); 
  20.  
  21. if ($SZ_ANALYTICS_OPTION_ADMIN['ga_position'] == 'F')  
  22. add_action('admin_footer', array(new SZGoogleActionAnalytics($this), 'action')); 
  23.  
  24. // Calling up the function of the parent class to process 
  25. // variables containing the values **of configuration section 
  26.  
  27. parent::__construct(); 
  28.  
  29. /** 
  30. * Creating the menu on the admin panel using values ** 
  31. * such as configuration variables object (parent function) 
  32. */ 
  33.  
  34. function moduleAddMenu() 
  35. // Definition of general values **for the creation of a menu associated  
  36. // with the module options. Example slug, page title and menu title 
  37.  
  38. $this->menuslug = 'sz-google-admin-analytics.php'; 
  39. $this->pagetitle = ucwords(__('google analytics', 'szgoogleadmin')); 
  40. $this->menutitle = ucwords(__('google analytics', 'szgoogleadmin')); 
  41.  
  42. // Definition of sections that need to be made **in HTML 
  43. // sections must be passed as an array of name = > title 
  44.  
  45. $this->sectionstabs = array( 
  46. '01' => array('anchor' => 'general' , 'description' => __('general' , 'szgoogleadmin')),  
  47. '02' => array('anchor' => 'classic' , 'description' => __('classic' , 'szgoogleadmin')),  
  48. '03' => array('anchor' => 'universal', 'description' => __('universal', 'szgoogleadmin')),  
  49. ); 
  50.  
  51. $this->sections = array( 
  52. array('tab' => '01', 'section' => 'sz-google-admin-analytics.php' , 'title' => ucwords(__('settings', 'szgoogleadmin'))),  
  53. array('tab' => '01', 'section' => 'sz-google-admin-analytics-enabled.php' , 'title' => ucwords(__('tracking', 'szgoogleadmin'))),  
  54. array('tab' => '02', 'section' => 'sz-google-admin-analytics-classic.php' , 'title' => ucwords(__('classic analytics', 'szgoogleadmin'))),  
  55. array('tab' => '03', 'section' => 'sz-google-admin-analytics-universal.php', 'title' => ucwords(__('universal analytics', 'szgoogleadmin'))),  
  56. ); 
  57.  
  58. $this->sectionstitle = $this->menutitle; 
  59. $this->sectionsoptions = array('sz_google_options_ga'); 
  60.  
  61. // Calling up the function of the parent class to process the  
  62. // variables that contain the values **of configuration section 
  63.  
  64. parent::moduleAddMenu(); 
  65.  
  66. /** 
  67. * Function to add sections and the corresponding options in the configuration 
  68. * page, each option belongs to a section, which is linked to a general tab  
  69. */ 
  70.  
  71. function moduleAddFields() 
  72. // General definition array containing a list of sections 
  73. // On every section you have to define an array to list fields 
  74.  
  75. $this->sectionsmenu = array( 
  76. '01' => array('section' => 'sz_google_analytics_section' , 'title' => $this->null, 'callback' => $this->callbacksection, 'slug' => 'sz-google-admin-analytics.php'),  
  77. '02' => array('section' => 'sz_google_analytics_enabled' , 'title' => $this->null, 'callback' => $this->callbacksection, 'slug' => 'sz-google-admin-analytics-enabled.php'),  
  78. '03' => array('section' => 'sz_google_analytics_classic' , 'title' => $this->null, 'callback' => $this->callbacksection, 'slug' => 'sz-google-admin-analytics-classic.php'),  
  79. '04' => array('section' => 'sz_google_analytics_universal', 'title' => $this->null, 'callback' => $this->callbacksection, 'slug' => 'sz-google-admin-analytics-universal.php'),  
  80. ); 
  81.  
  82. // General definition array containing a list of fields 
  83. // All fields are added to the previously defined sections 
  84.  
  85. $this->sectionsfields = array( 
  86. '01' => array(array('field' => 'ga_uacode' , 'title' => ucwords(__('UA code' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_uacode')),  
  87. array('field' => 'ga_position' , 'title' => ucfirst(__('position' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_position')),  
  88. array('field' => 'ga_type' , 'title' => ucfirst(__('type code' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_type')),  
  89. array('field' => 'ga_compression' , 'title' => ucfirst(__('compression' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_compression')), ),  
  90. '02' => array(array('field' => 'ga_enable_front' , 'title' => ucfirst(__('frontend' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_front')),  
  91. array('field' => 'ga_enable_admin' , 'title' => ucfirst(__('backend' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_admin')),  
  92. array('field' => 'ga_enable_admin_administrator', 'title' => ucfirst(__('administrator' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_administrator')),  
  93. array('field' => 'ga_enable_admin_logged' , 'title' => ucfirst(__('user logged' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_logged')), ),  
  94. '03' => array(array('field' => 'ga_enable_subdomains' , 'title' => ucfirst(__('tracking subdomains' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_subdomains')),  
  95. array('field' => 'ga_enable_multiple' , 'title' => ucfirst(__('multiple top domains', 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_multiple')),  
  96. array('field' => 'ga_enable_advertiser' , 'title' => ucfirst(__('advertiser' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_advertiser')),  
  97. array('field' => 'ga_enable_ip_none_cl' , 'title' => ucfirst(__('IP Anonymization' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_ip_none_cl')),  
  98. array('field' => 'ga_enable_cl_proxy' , 'title' => ucfirst(__('Proxy HTTP' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_cl_proxy')),  
  99. array('field' => 'ga_enable_cl_proxy_url' , 'title' => ucfirst(__('Proxy HTTP URL' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_cl_proxy_url')),  
  100. array('field' => 'ga_enable_cl_proxy_adv' , 'title' => ucfirst(__('Proxy HTTP URL adv' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_cl_proxy_adv')), ),  
  101. '04' => array(array('field' => 'ga_enable_ip_none_ad' , 'title' => ucfirst(__('IP Anonymization' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_ip_none_ad')),  
  102. array('field' => 'ga_enable_features' , 'title' => ucfirst(__('display features' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_features')),  
  103. array('field' => 'ga_enable_un_proxy' , 'title' => ucfirst(__('Proxy HTTP' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_un_proxy')),  
  104. array('field' => 'ga_enable_un_proxy_url' , 'title' => ucfirst(__('Proxy HTTP URL' , 'szgoogleadmin')), 'callback' => array($this, 'callback_analytics_enable_un_proxy_url')), ),  
  105. ); 
  106.  
  107. // Calling up the function of the parent class to process the  
  108. // variables that contain the values **of configuration section 
  109.  
  110. parent::moduleAddFields(); 
  111.  
  112. /** 
  113. * Definition functions for the creation of the various options that should be included  
  114. * in the general form of configuration and saved on a database of wordpress (options) 
  115. */ 
  116.  
  117. function callback_analytics_uacode() 
  118. $this->moduleCommonFormText('sz_google_options_ga', 'ga_uacode', 'medium', __('insert your UA code', 'szgoogleadmin')); 
  119. $this->moduleCommonFormDescription(__('specify the code assigned to the profile of google analytics, to find enough to enter the admin panel google analytics and see the code assigned such as UA-12345-12. If this code is not specified will not be generated the tracking code for google analytics.', 'szgoogleadmin')); 
  120.  
  121. /** 
  122. * Definition functions for the creation of the various options that should be included  
  123. * in the general form of configuration and saved on a database of wordpress (options) 
  124. */ 
  125.  
  126. function callback_analytics_position() 
  127. $values = array( 
  128. 'H' => __('header (default)', 'szgoogleadmin'),  
  129. 'F' => __('footer', 'szgoogleadmin'),  
  130. 'M' => __('insert manually', 'szgoogleadmin'),  
  131. ); 
  132.  
  133. $this->moduleCommonFormSelect('sz_google_options_ga', 'ga_position', $values, 'medium', ''); 
  134. $this->moduleCommonFormDescription(__('specifies the location of the tracking code in the page HTML. The recommended position is the header that does not allow the loss of access statistics. If you specify the manual mode you have to use szgoogle_analytics_get_code().', 'szgoogleadmin')); 
  135.  
  136. function callback_analytics_type() 
  137. $values = array( 
  138. 'classic' => __('google analytics classic', 'szgoogleadmin'),  
  139. 'universal' => __('google analytics universal', 'szgoogleadmin'),  
  140. );  
  141.  
  142. $this->moduleCommonFormSelect('sz_google_options_ga', 'ga_type', $values, 'medium', ''); 
  143. $this->moduleCommonFormDescription(__('universal Analytics introduces a set of features that change the way data is collected and organized in your Google Analytics account, so you can get a better understanding of how visitors interact with your online content.', 'szgoogleadmin')); 
  144.  
  145. function callback_analytics_compression() 
  146. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_compression'); 
  147. $this->moduleCommonFormDescription(__('enable this option to compress the HTML code that is placed in the WEB page by the plugin. This option need to be current with those using an HTML minimized to create their own web pages. It works both for the header that footer.', 'szgoogleadmin')); 
  148.  
  149. /** 
  150. * Definition functions for the creation of the various options that should be included  
  151. * in the general form of configuration and saved on a database of wordpress (options) 
  152. */ 
  153.  
  154. function callback_analytics_enable_front() 
  155. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_front'); 
  156. $this->moduleCommonFormDescription(__('enable this option to activate the tracking code to the public pages of your website. This option can also be used to disable the code without disabling the module. To check the tracking code on the basis of connected users use others options.', 'szgoogleadmin')); 
  157.  
  158. function callback_analytics_enable_admin() 
  159. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_admin'); 
  160. $this->moduleCommonFormDescription(__('this option allows you to insert the tracking code in the admin pages. Useful function for some tests but not recommended during normal operation. Do not confuse this option with the administrator user which controls the type of user logged.', 'szgoogleadmin')); 
  161.  
  162. function callback_analytics_enable_administrator() 
  163. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_administrator'); 
  164. $this->moduleCommonFormDescription(__('this option allows you to enter the tracking code when you browse the website as an administrator user. It is recommended to leave this option off as not to affect access statistics. This option is used for both the frontend and backend environment.', 'szgoogleadmin')); 
  165.  
  166. function callback_analytics_enable_logged() 
  167. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_logged'); 
  168. $this->moduleCommonFormDescription(__('with this option, you can check the tracking code for users who are connected to the website. The behavior of this option is similar to option regarding the administrator user. This option is used for both the frontend and backend environment.', 'szgoogleadmin')); 
  169.  
  170. /** 
  171. * Definition functions for the creation of the various options that should be included  
  172. * in the general form of configuration and saved on a database of wordpress (options) 
  173. */ 
  174.  
  175. function callback_analytics_enable_subdomains() 
  176. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_subdomains'); 
  177. $this->moduleCommonFormDescription(__('turn this option for track your subdomains. This option adds the _setDomainName function to your code. Use this function if you manage multiple domains as example www.domain.com, apps.domain.com and store.domain.com', 'szgoogleadmin')); 
  178.  
  179. function callback_analytics_enable_multiple() 
  180. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_multiple'); 
  181. $this->moduleCommonFormDescription(__('turn this option on to track across multiple top-level domains. This option adds the _setDomainName and _setAllowLinker to tracking code. Use this function if you manage multiple domains as example domain.uk, domain.cn and domain.fr', 'szgoogleadmin')); 
  182.  
  183. function callback_analytics_enable_advertiser() 
  184. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_advertiser'); 
  185. $this->moduleCommonFormDescription(__('turn this option for enable display advertiser support. This change is compatible with both the synchronous and asynchronous versions of the tracking code. This modification does not impact any customizations you have previously made to your code.', 'szgoogleadmin')); 
  186.  
  187. function callback_analytics_enable_ip_none_cl() 
  188. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_ip_none_cl'); 
  189. $this->moduleCommonFormDescription(__('in some cases, you might need to anonymize the IP address of the hit (http request) sent to Google Analytics. This function can also be useful for the new European legislation on cookies.', 'szgoogleadmin')); 
  190.  
  191. function callback_analytics_enable_cl_proxy() 
  192. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_cl_proxy'); 
  193. $this->moduleCommonFormDescription(__('there may be situations where you want to make a proxy on request script google GA. For example, useful when you want to change the values **of Cache. Obviously the proxy configuration should be performed at the webserver like Apache.', 'szgoogleadmin')); 
  194.  
  195. function callback_analytics_enable_cl_proxy_url() 
  196. $this->moduleCommonFormText('sz_google_options_ga', 'ga_enable_cl_proxy_url', 'large', __('insert URL as domain.com/URL dont\'use (http://)', 'szgoogleadmin')); 
  197. $this->moduleCommonFormDescription(__('if you have enabled the HTTP Proxy can indicate the URL address on which to run the local operation PROXY. For example you can use domain.com/cache/ga.js to run the proxy on www.google-analytics.com/ga.js. Dont\'use prefix (http://).', 'szgoogleadmin')); 
  198.  
  199. function callback_analytics_enable_cl_proxy_adv() 
  200. $this->moduleCommonFormText('sz_google_options_ga', 'ga_enable_cl_proxy_adv', 'large', __('insert URL as domain.com/URL dont\'use (http://)', 'szgoogleadmin')); 
  201. $this->moduleCommonFormDescription(__('if you have enabled the HTTP Proxy can indicate the URL address on which to run the local operation PROXY. For example you can use domain.com/cache/advertiser.js to run the proxy on stats.g.doubleclick.net/dc.js. Dont\'use prefix (http://).', 'szgoogleadmin')); 
  202.  
  203. /** 
  204. * Definition functions for the creation of the various options that should be included  
  205. * in the general form of configuration and saved on a database of wordpress (options) 
  206. */ 
  207.  
  208. function callback_analytics_enable_ip_none_ad() 
  209. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_ip_none_ad'); 
  210. $this->moduleCommonFormDescription(__('in some cases, you might need to anonymize the IP address of the hit (http request) sent to Google Analytics. This function can also be useful for the new European legislation on cookies.', 'szgoogleadmin')); 
  211.  
  212. function callback_analytics_enable_features() 
  213. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_features'); 
  214. $this->moduleCommonFormDescription(__('Google Analytics Display Advertising is a collection of features that takes advantage of the DoubleClick cookie so you can do things like create remarketing lists, use demographic data and create segments based on demographic and interest data.', 'szgoogleadmin')); 
  215.  
  216. function callback_analytics_enable_un_proxy() 
  217. $this->moduleCommonFormCheckboxYesNo('sz_google_options_ga', 'ga_enable_un_proxy'); 
  218. $this->moduleCommonFormDescription(__('there may be situations where you want to make a proxy on request script google GA. For example, useful when you want to change the values **of Cache. Obviously the proxy configuration should be performed at the webserver like Apache.', 'szgoogleadmin')); 
  219.  
  220. function callback_analytics_enable_un_proxy_url() 
  221. $this->moduleCommonFormText('sz_google_options_ga', 'ga_enable_un_proxy_url', 'large', __('insert URL as domain.com/URL dont\'use (http://)', 'szgoogleadmin')); 
  222. $this->moduleCommonFormDescription(__('if you have enabled the HTTP Proxy can indicate the URL address on which to run the local operation PROXY. For example you can use domain.com/cache/ga.js to run the proxy on www.google-analytics.com/analytics.js. Dont\'use prefix (http://).', 'szgoogleadmin'));