內容簡介
Tracking Code For Google Analytics 是一個簡單、輕量級的 WordPress 外掛,可插入 Google Analytics Universal Analytics 追蹤碼。 這個外掛只有一個功能,就是將標準的 Google Analytics 追蹤腳本列印到網站的 <head>。要插入追蹤代碼,請前往「設定」 >「常規」,然後滾動到頁面底部。
Composer
composer require claytoncollie/tracking-code-for-google-analytics
過慮器
如果您希望在不使用 wp-admin 使用者介面的情況下設置追蹤 ID,請使用下面的過濾器。
add_filter(
'tracking_code_for_google_analytics_id',
/**
* 設置 Google Analytics 追蹤 ID。
*
* @param string $tracking_id 追蹤 ID。
*
* @return string
*/
function ( string $tracking_id ) : string {
$tracking_id = 'UA-7654321';
return $tracking_id;
}
);
定義
您也可以使用以下程式片段在 wp-config.php 文件中定義追蹤 ID。
define( 'TRACKING_CODE_FOR_GOOGLE_ANALYTICS_ID', 'UA-7654321' );
貢獻
儘管此外掛的目的是非常嚴密的範圍,但 歡迎在 GitHub 上提交問題和拉取請求。 我並不保證所有事情都會被合併或提供支持。
捐贈
如果您喜歡這個外掛,並希望支持我的工作,請考慮通過 Coinbase 進行小額捐贈。
外掛標籤
開發者團隊
② 後台搜尋「Tracking Code for Google Analytics」→ 直接安裝(推薦)
原文外掛簡介
Tracking Code For Google Analytics is a simple, lightweight WordPress plugin for inserting your Google Analytics Universal Analytics tracking code. The plugin does one thing and one thing only; prints the standard Google Analytics tacking script to the
of your website. To insert your tracking ID, navigate to Settings > General and then scroll to the bottom of the page.Composer
composer require claytoncollie/tracking-code-for-google-analytics
Filters
If you want to set the tracking ID without using the wp-admin user interface, use the filter below.
add_filter(
'tracking_code_for_google_analytics_id',
/**
* Set Google Analytics tracking ID.
*
* @param string $tracking_id Tracking ID.
*
* @return string
*/
function ( string $tracking_id ) : string {
$tracking_id = 'UA-7654321';
return $tracking_id;
}
);
Definitions
You can also define the tracking ID in your wp-config.php file with the following snippet.
define( 'TRACKING_CODE_FOR_GOOGLE_ANALYTICS_ID', 'UA-7654321' );
Contributing
While the purpose of this plugin is to be very tightly scoped, issues and pull requests are welcome on GitHub. I do not guarantee that everything will be merged or support will be given.
Donate
If you like this plugin and would like to support my work, please consider a small donation via Coinbase.
