[WordPress] 外掛分享: Metronet Tag Manager

首頁外掛目錄 › Metronet Tag Manager
WordPress 外掛 Metronet Tag Manager 的封面圖片
20,000+
安裝啟用
★★★★
4.8/5 分(8 則評價)
95 天前
最後更新
問題解決
WordPress 4.2+ v1.5.5 上架:2013-07-23

內容簡介

將 Google Tag Manager 整合到您的網站中。

Google Tag Manager(GTM)的好處是您能夠在一個地方收集大部分的追蹤腳本。然後,您可以按照您設置的規則隨時啟動這些腳本。聽起來不錯,對吧?實際上確實如此。唯一的問題是有時候需要一點實現來設置這些規則。實現可以是在載入標籤管理器腳本之前在資料層中設置資料層變數,或者在單擊按鈕時將帶有“事件”變數的 HTML 事件處理程序推送到資料層中。當您無法將代碼添加到您的網站上時,這就不那麼容易做到。

這就是 Metronet Tag Manager 外掛的優勢所在。它真正發揮了數據層的功能,因此您可以在幾乎任何元素上輕鬆設置宏和觸發規則。

此外,此外掛還可以讓您:

以每個文章和每個頁面為基礎輕鬆添加許多資料層變數。
外掛已經為您提供了六個預定義的數據層變數,您可以更改/刪除或使用這些變數測試系統。這些將載入到所有頁面和文章中。
為不是文章或頁面的頁面(例如檔案庫等)設置單獨的數據層變數。
使用 WYSIWYG 中的 GTM TinyMCE 按鈕輕鬆地為任何內容鏈接添加 HTML 事件處理程序。
使用 WYSIWYG 中的 GTM TinyMCE 按鈕輕鬆地為每個內容鏈接添加您自己的獨特 ID 或類別。

請注意,為使此外掛正常運作,需要進行輕微的自定義。 WordPress 不允許您在開始的 <body> 標籤後直接載入腳本,這是 GTM 腳本需要放置的地方。為了修正這個問題,您需要在 <body> 標籤之後添加<?php do_action('body_open'); ?> ,就這樣。

請注意,如果您使用的是 WordPress 5.2 或更新版本,請聯繫您的主題開發人員,要求他們在主題的開始標籤後插入<?php wp_body_open(); ?> 。這里是一些代碼,以顯示主題開發人員以使其與Metronet Tag Manager相容。

如果您對此外掛有任何功能請求或問題,請告訴我們。

以下是一些資源,如果您是 Google Tag Manager 的新手,您可能會發現有價值:

官方 Google Tag Manager 網站。
https://developers.google.com/tag-manager/

使用 Google Tag Manager 跟踪 Google Analytics 事件。
http://moz.com/ugc/tracking-google-analytics-events-with-google-tag-manager

使用標籤管理和數據層使分析更好。
http://cutroni.com/blog/2012/05/14/make-analytics-better-with-tag-management-and-a-data-layer/

篩選變數

如果您選擇將變數值放在百分比符號中(例如,%replace_test%),您可以根據需要進行篩選。

以下是一個示例:

add_filter ('gtm_replace_test', 'gtm_replace_test', 10, 3);
function gtm_replace_test( $total_match, $match, $post_id ) {
return "replaced with content";
}

篩選器名稱為 gtm_,後綴為 replace_test,因為那個內容處於百分比符號之間。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.5.5) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Metronet Tag Manager」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Integrate Google Tag Manager into your website.
The great thing about Google Tag Manager (GTM) is that you are able to gather most of your tracking scripts in one place. You can then fire these scripts whenever you want, specified by the rules you set up. This sounds great, right? Well, it is. The only problem is that sometimes it takes some time to set these rules up. This implementation can either set a dataLayer variable in the dataLayer before the tag manager script is loaded or push an HTML event handler with the variable “event” to the dataLayer when a button is clicked. The problem is that this isn’t always that easy to do when you don’t have the ability/access to add the code to your site.
This is where the Metronet Tag Manager plugin shines. It unlocks the power of the dataLayer so you can easily set macros and firing rules on almost any element.
This plugin lets you:

Easily add as many dataLayer variables per-post and per-page basis as needed.
The plugin already gives you six predefined dataLayer variables you can change/remove or test the system with. These will be loaded on all pages and posts.
Set up separate dataLayer variables for pages that aren’t posts or pages (like archives, etc).
Lets you easily add an HTML event handler to any content link with the GTM TinyMCE button in the WYSIWYG.
Lets you add your unique ID or a class to each content link with the GTM TinyMCE button in the WYSIWYG.

Please note that for this plugin to work, a slight customization is needed. WordPress doesn’t let you load scripts straight after the opening tag, where the GTM script needs to be placed to work correctly. To fix this, you need to add just after the tag, and that’s it.

Note, If you are using WordPress 5.2. and up, contact your theme developer and ask them to insert just after the opening body tag of their theme. Here is some code to show the theme developer to make it compatible with Metronet Tag Manager.

Please let us know if you have any feature requests or issues with this plugin.
Below are a couple of resources you might find valuable if you are new to Google Tag Manager
Official Google Tag Manager website
https://developers.google.com/tag-manager/
Tracking Google Analytics Events with Google Tag Manager

How to Track Pdf Downloads with Tag Manager on WordPress


Make Analytics Better with Tag Management and a Data Layer

The Benefits of Using a Tag Manager Plugin on WordPress


Filtering Variables
If you choose to place variable values inside percentage signs (e.g., %replace_test%), you can filter these as necessary.
Here’s an example:
add_filter( 'gtm_replace_test', 'gtm_replace_test', 10, 3 );
function gtm_replace_test( $total_match, $match, $post_id ) {
return "replaced with content";
}

The filter name is gtm_ with the suffix of replace_test, since that content is inbetween the percentage signs.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon