DCO Insert Analytics Code

Description

DCO Insert Analytics Code is a WordPress plugin is intended for insert analytics code(or any custom code) before </head> or after <body> or before </body>

Usage

After installation and activation, you can insert the necessary code to the respective fields on the plugin settings page.

Settings

  • Before </head> code
  • After <body> code
  • Before </body> code

Filters list

dco_iac_get_options

Filter for hardcoding override plugin settings. You won’t be able to edit them on the settings page anymore when using this filter.

dco_iac_insert_before_head

Filter to change the code is inserted before </head>

dco_iac_insert_before_head_show

Filter to change show the code is inserted before </head>

dco_iac_insert_after_body

Filter to change the code is inserted after <body>

dco_iac_insert_after_body_show

Filter to change show the code is inserted after <body>

dco_iac_insert_before_body

Filter to change the code is inserted before </body>

dco_iac_insert_before_body_show

Filter to change show the code is inserted before </body>

Examples of using filters

Hardcoding override plugin settings
function custom_get_options($current, $options, $default) {
$array = array(
‘before_head’ => ‘<!– before –>’,
‘before_head_show’ => ‘0’,
‘after_body’ => ‘<!– after –>’,
‘after_body_show’ => ‘1’,
‘before_body’ => ‘<!– before –>’,
‘before_body_show’ => ‘2’
);

    return $array;
}

add_filter('dco_iac_get_options', 'custom_get_options', 10, 3);

/*
* $current - current plugin settings
*
* $options - plugin settings from database
*
* $default - default plugin settings
*/

Change before </head> code
function custom_before_head_code( $code ) {
return $code . ‘<!– before –>’ . “\n”;
}

add_filter( 'dco_iac_insert_before_head', 'custom_before_head_code' );

/*
* $code - value from "before </head>" setting
*/

Change before </body> code show
function custom_before_head_code( $value ) {
return ‘2’;
}

add_filter( 'dco_iac_insert_before_body_show', 'custom_before_body_show' );

/*
* $value - value from "before </body> show" setting
*/

Screenshots

  • Settings page
  • Example page

Installation

  1. Upload dco-insert-analytics-code folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress

FAQ

Installation Instructions
  1. Upload dco-insert-analytics-code folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
I put the code on the plugin settings page, but it does not appear on the site. What could be the reason?

Reviews

Does exactly what is says on the tin

Great little plugin for adding tracking codes and other scripts to a website. I had one issue with it working which was caused by a caching issue and nothing to do with the plugin, but the author still responded to me very quickly after posting in the support forums.

Отлично!

Отличный плагин. Давно искал такой.
Будет идеальный, если добавить опцию учитывать или нет залогиненого пользователя, и выбор какие роли учитывать, а какие нет.

Read all 3 reviews

Contributors & Developers

“DCO Insert Analytics Code” is open source software. The following people have contributed to this plugin.

Contributors

“DCO Insert Analytics Code” has been translated into 1 locale. Thank you to the translators for their contributions.

Translate “DCO Insert Analytics Code” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

1.1.3

  • Add settings link to Plugins page
  • Correct plugin description

1.1.2

  • Constant DCO_IAC_DO_SHORTCODE replaced with dco_iac_disable_do_shortcode filter. Use add_filter('dco_iac_disable_do_shortcode', '__return_true'); to disable shortcodes support.

1.1.1

  • Added feature to hide the code
  • Added shortcodes support (add constant define('DCO_IAC_DO_SHORTCODE', false); to wp-config.php for disable)

1.1.0

  • Fixed Text Domain
  • Added the ability to adjust the show code for logged / not logged users
  • Restricted direct access to plugin files

1.0.0

  • Initial Release