How to Add a Custom Search Engine in WP Statistics with Filter

How to Add a Custom Search Engine in WP Statistics with Filter

WP Statistics is a popular WordPress plugin that provides detailed insights into your website’s traffic. It can track visitors, page views, search terms, and more. One of its features is the ability to track which search engines your visitors are using to find your website.

By default, WP Statistics tracks the following search engines:

However, you can also add custom search engines to WP Statistics. This is useful if you want to track traffic from other search engines, such as Naver or Daum.

To add a custom search engine to WP Statistics, you can use the following filter:

PHP

add_filter('wp_statistics_search_engine_list', function ($engines) {

    $engines['naver'] = [
        'name' => 'Naver',
        'translated' => __('Naver', 'wp_statistics'),
        'tag' => 'naver',
        'sqlpattern' => '%naver.com%',
        'regexpattern' => 'naver.com',
        'querykey' => 'query',
        'image' => 'naver.png',
        'logo_url' => 'naver.png'
    ];

    $engines['daum'] = [
        'name' => 'Daum',
        'translated' => __('Daum', 'wp_statistics'),
        'tag' => 'daum',
        'sqlpattern' => '%daum.net%',
        'regexpattern' => 'daum\.net',
        'querykey' => 'q',
        'image' => 'daum.png',
        'logo_url' => 'daum.png'
    ];

    return $engines;
});

This filter will add two new search engines to WP Statistics: Naver and Daum. You can customize the filter to add additional search engines, as well as modify the search engine information (e.g., name, tag, logo).

Related Document: Basic Tracking Settings

Let’s get started
Take your business to next level

Become part of our growing family of +600,000 users and get the tools you need to make smart choices for your website. Simple, powerful insights are just a click away.