php 将内置的Google Analytics + API密钥替换为自定义密钥,以避免达到每日限制。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 将内置的Google Analytics + API密钥替换为自定义密钥,以避免达到每日限制。相关的知识,希望对你有一定的参考价值。

<?php
/**
* Plugin Name: Change Google Analytics API Keys
* Plugin URI: https://premium.wpmudev.org/project/google-analytics-for-wordpress-mu-sitewide-and-single-blog-solution/
* Description: Replace the built in Google Analytics API Keys with custom ones to avoid hitting the daily limits.
* Author: Lindeni Mahlalela @ WPMUDEV
* Author URI: https://premium.wpmudev.org/profile/mahlamusa
* License: GPLv2 or later
*/

if ( ! function_exists( 'change_ga_project_client_id' ) ) {
    add_filter('ga_project_client_id', 'change_ga_project_client_id', 10, 1);
    function change_ga_project_client_id( $client_id ) {
        return "your project client ID";
    }
}

if ( ! function_exists( 'change_ga_project_client_secret' ) ) {
    add_filter('ga_project_client_secret', 'change_ga_project_client_secret', 10, 1);
    function change_ga_project_client_secret( $client_secret ) {
        return "your client_secrete";
    }
}

if ( ! function_exists( 'change_ga_project_key' ) ) {
    add_filter('ga_project_key', 'change_ga_project_key', 10, 1);
    function change_ga_project_key( $project_key ) {
        return "your project key";
    }
}

以上是关于php 将内置的Google Analytics + API密钥替换为自定义密钥,以避免达到每日限制。的主要内容,如果未能解决你的问题,请参考以下文章

php 将Google Analytics跟踪代码添加到WordPress的简单插件

php 将Google Analytics跟踪代码添加到WordPress的简单插件

text 将Google Analytics添加到WordPress主题functions.php

Google Analytics Reporting Api - PHP:添加用户帐户

php Wordpress functions.php片段使用Yoast的插件将Google Analytics跟踪添加到wp_nav_menu

Google Analytics PHP示例