Title: DCO Insert Analytics Code
Author: Denis Yanchevskiy
Published: <strong>January 16, 2016</strong>
Last modified: July 28, 2021

---

Search plugins

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://ps.w.org/dco-insert-analytics-code/assets/icon.svg?rev=1806013)

# DCO Insert Analytics Code

 By [Denis Yanchevskiy](https://profiles.wordpress.org/denisco/)

[Download](https://downloads.wordpress.org/plugin/dco-insert-analytics-code.1.1.3.zip)

 * [Details](https://wordpress.org/plugins/dco-insert-analytics-code/#description)
 * [Reviews](https://wordpress.org/plugins/dco-insert-analytics-code/#reviews)
 *  [Installation](https://wordpress.org/plugins/dco-insert-analytics-code/#installation)
 * [Development](https://wordpress.org/plugins/dco-insert-analytics-code/#developers)

 [Support](https://wordpress.org/support/plugin/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](https://github.com/yadenis/DCO-Insert-Analytics-Code)

#### 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');
    ```

## 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

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

 * For correct work plugin your theme must support [wp_head action hook](https://developer.wordpress.org/reference/functions/wp_head/)
   and [wp_footer action hook](https://developer.wordpress.org/reference/functions/wp_footer/).
 * If you are using plugins for caching you need to clear the cache to apply the
   changes.

## Reviews

![](https://secure.gravatar.com/avatar/649fb2ded934d53d79b98a1f98c694d175ef9c644e28b89ea0eb8c3a64fdda39?
s=60&d=retro&r=g)

### 󠀁[Never edit theme files anymore](https://wordpress.org/support/topic/never-edit-theme-files-anymore/)󠁿

 [Yui](https://profiles.wordpress.org/fierevere/) April 3, 2021

Very light plugin that will make editing theme parts unnecessary. * header.php *
footer.php Safe! No possibility to break things, can be used by newbies. Suitable
for anything. * counters, analytics code * site verification with <meta> tags * 
adding loading additional scripts and styles or using them inline. * much more.

![](https://secure.gravatar.com/avatar/dbdd1319be33f8844aab507cccadd479800fdcc639419f3ddbad6951fdd96e3a?
s=60&d=retro&r=g)

### 󠀁[Мультисайт вп](https://wordpress.org/support/topic/%d0%bc%d1%83%d0%bb%d1%8c%d1%82%d0%b8%d1%81%d0%b0%d0%b9%d1%82-%d0%b2%d0%bf/)󠁿

 [igor420](https://profiles.wordpress.org/igor420/) August 8, 2019 1 reply

Не хватает поддержки мультисайтовости. Очень просим

![](https://secure.gravatar.com/avatar/a8db7ea96a724a993d5ee8ec7edaf9a1f7c457426aeaf5e622d25bf604049e7d?
s=60&d=retro&r=g)

### 󠀁[Excellent Plugin](https://wordpress.org/support/topic/excellent-plugin-4871/)󠁿

 [blmbmj](https://profiles.wordpress.org/blmbmj/) May 10, 2019

Allows precise insertion of code at many template locations. Light, simply and works
well! Thank you.

![](https://secure.gravatar.com/avatar/1069b216c5de56588a7726ad6a487032e9b9d48fe9b1b831c73f1c7807f443f5?
s=60&d=retro&r=g)

### 󠀁[Great!](https://wordpress.org/support/topic/great-9279/)󠁿

 [bobbobbius](https://profiles.wordpress.org/bobbobbius/) February 19, 2019

i like it

![](https://secure.gravatar.com/avatar/35450a7872f68f28db0bb4e56895481d6b52bf259af1493c533b4de84c646b88?
s=60&d=retro&r=g)

### 󠀁[Simple & Functional](https://wordpress.org/support/topic/simple-functional-9/)󠁿

 [jc123](https://profiles.wordpress.org/jc123/) November 24, 2018

Thank you.

![](https://secure.gravatar.com/avatar/34134c14629645d633557bebd75676cdcceae803d71ade07f4e26c09501d08f7?
s=60&d=retro&r=g)

### 󠀁[Works with the plugin Elementor Page Builder](https://wordpress.org/support/topic/works-with-the-plugin-elementor-page-builder/)󠁿

 [Vad](https://profiles.wordpress.org/vadym1/) April 13, 2018

The code for analytics needed to be displayed on all pages including pages created
in Elementor Page Builder. This plugin helped solve this issue.

 [ Read all 8 reviews ](https://wordpress.org/support/plugin/dco-insert-analytics-code/reviews/)

## Contributors & Developers

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

Contributors

 *   [ Denis Yanchevskiy ](https://profiles.wordpress.org/denisco/)

“DCO Insert Analytics Code” has been translated into 2 locales. Thank you to [the translators](https://translate.wordpress.org/projects/wp-plugins/dco-insert-analytics-code/contributors)
for their contributions.

[Translate “DCO Insert Analytics Code” into your language.](https://translate.wordpress.org/projects/wp-plugins/dco-insert-analytics-code)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/dco-insert-analytics-code/),
check out the [SVN repository](https://plugins.svn.wordpress.org/dco-insert-analytics-code/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/dco-insert-analytics-code/)
by [RSS](https://plugins.trac.wordpress.org/log/dco-insert-analytics-code/?limit=100&mode=stop_on_copy&format=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

## Meta

 *  Version **1.1.3**
 *  Last updated **5 years ago**
 *  Active installations **4,000+**
 *  WordPress version ** 4.6 or higher **
 *  Tested up to **5.8.13**
 *  PHP version ** 5.3 or higher **
 *  Languages
 * [English (US)](https://wordpress.org/plugins/dco-insert-analytics-code/), [Russian](https://ru.wordpress.org/plugins/dco-insert-analytics-code/),
   and [Swedish](https://sv.wordpress.org/plugins/dco-insert-analytics-code/).
 *  [Translate into your language](https://translate.wordpress.org/projects/wp-plugins/dco-insert-analytics-code)
 * Tags
 * [analytics](https://wordpress.org/plugins/tags/analytics/)[google analytics](https://wordpress.org/plugins/tags/google-analytics/)
   [metrika](https://wordpress.org/plugins/tags/metrika/)[yandex metrica](https://wordpress.org/plugins/tags/yandex-metrica/)
 *  [Advanced View](https://wordpress.org/plugins/dco-insert-analytics-code/advanced/)

## Ratings

 5 out of 5 stars.

 *  [  8 5-star reviews     ](https://wordpress.org/support/plugin/dco-insert-analytics-code/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/dco-insert-analytics-code/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/dco-insert-analytics-code/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/dco-insert-analytics-code/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/dco-insert-analytics-code/reviews/?filter=1)

[Add my review](https://wordpress.org/support/plugin/dco-insert-analytics-code/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/dco-insert-analytics-code/reviews/)

## Contributors

 *   [ Denis Yanchevskiy ](https://profiles.wordpress.org/denisco/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/dco-insert-analytics-code/)