Search Over 30,000 FREE Plugins from the Official WordPress Plugin Directory Repository

DCO Insert Analytics Code

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

GitHub

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 </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);

/*
* $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 <head> -->' . "\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
*/
Author Denis co.
Profile
Contributors denisco
Tags analytics, google analytics, metrika, yandex metrica
  1. dco-insert-analytics-code screenshot 1

    Settings page

  2. dco-insert-analytics-code screenshot 2

    Example page

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

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

I put the code on the plugin settings page, but it does not appear on the site. What could be the reason?

Share  
Download
Version 1.1.0

Requires WordPress version: 4.4 or higher

Compatible up to: 4.7.2

Last Updated 08 Jan 2017

Date Added: 16 Jan 2016

Plugin Homepage

Evaluation
star1
star2
star3
star4
star5

5 stars
1 ratings
1,720 downloads

Compatibility

Not Enough Data

Reports:
Works: 0
Broken: 0