Home Plugins dco insert analytics code
DCO Insert Analytics Code logo

DCO Insert Analytics Code

by Denis Yanchevskiy on WordPress.org

Allows you to insert analytics code before </head> or after <body> or before </body>

(8)
Settings page

Settings page

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

Usage

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

Settings

  • Before code
  • After code
  • Before 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

dco_iac_insert_before_head_show

Filter to change show the code is inserted before

dco_iac_insert_after_body

Filter to change the code is inserted after

dco_iac_insert_after_body_show

Filter to change show the code is inserted after

dco_iac_insert_before_body

Filter to change the code is inserted before

dco_iac_insert_before_body_show

Filter to change show the code is inserted before

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_show' => '0',
        'after_body' => '',
        'after_body_show' => '1',
        'before_body' => '',
        'before_body_show' => '2'
    );

    return $array;
}

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

Change before code

/*
* $code - value from "before " setting
*/

function custom_before_head_code( $code ) {
    return $code . '' . "\n";
}

add_filter( 'dco_iac_insert_before_head', 'custom_before_head_code' );

Change before code show

/*
* $value - value from "before  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');
Active installations5K+
Weekly downloads
28-26.32%
Version1.1.3
Last updated7/28/2021
WordPress version4.6
Tested up to5.8.10
PHP version5.3
Tags
analyticsgoogle analyticsmetrikayandex metrica