DCO Insert Analytics Code
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.
GitHub
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>
dco_iac_disable_do_shortcode
Filter to disable shortcode processing in inserted codes
Examples of using filters
Hardcoding override plugin settings
/*
* $current - current plugin settings
*
* $options - plugin settings from database
*
* $default - default plugin settings
*/
function custom_get_options($current, $options, $default) {
$array = array(
'before_head' => '<!-- before </head> -->',
'before_head_show' => '0',
'after_body' => '<!-- after <body> -->',
'after_body_show' => '1',
'before_body' => '<!-- before </body> -->',
'before_body_show' => '2'
);
return $array;
}
add_filter('dco_iac_get_options', 'custom_get_options', 10, 3);
Change before </head> code
/*
* $code - value from "before </head>" setting
*/
function custom_before_head_code( $code ) {
return $code . '<!-- before <head> -->' . "\n";
}
add_filter( 'dco_iac_insert_before_head', 'custom_before_head_code' );
Change before </body> code show
/*
* $value - value from "before </body> show" setting
*/
function custom_before_head_code( $value ) {
return '2';
}
add_filter( 'dco_iac_insert_before_body_show', 'custom_before_body_show' );
Disable shortcode processing in insert codes
add_filter('dco_iac_disable_do_shortcode', '__return_true');
Installation
- Upload
dco-insert-analytics-codefolder to the/wp-content/plugins/directory - Activate the plugin through the ‘Plugins’ menu in WordPress
Faq
- For correct work plugin your theme must support wp_head action hook and wp_footer action hook.
- If you are using plugins for caching you need to clear the cache to apply the changes.
Reviews
Never edit theme files anymore
By Yui (fierevere) on April 3, 2021
Мультисайт вп
By igor420 on August 8, 2019
Excellent Plugin
By blmbmj on May 10, 2019
Great!
By bobbobbius on February 19, 2019
Simple & Functional
By jc123 on November 24, 2018
Works with the plugin Elementor Page Builder
By Vad (vadym1) on April 13, 2018
Does exactly what is says on the tin
By jamesseoptiks on March 30, 2018
Отлично!
By antdmi on September 3, 2016
Отличный плагин. Давно искал такой.
Будет идеальный, если добавить опцию учитывать или нет залогиненого пользователя, и выбор какие роли учитывать, а какие нет.
Changelog
1.1.3
- Add settings link to Plugins page
- Correct plugin description
1.1.2
- Constant
DCO_IAC_DO_SHORTCODEreplaced withdco_iac_disable_do_shortcodefilter. Useadd_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

