
內容簡介
由 Logic Hop 製作的 Monarch 回撥外掛:在 Monarch 社交分享外掛中添加了一個JavaScript回撥功能。只需安裝外掛,當單擊任何 Monarch 社交分享或追蹤按鈕時,就會自動提供回調。
現在,您可以在社交分享或追蹤按鈕被點擊時觸發自定義事件。該回調可在頁面,文章或JavaScript文件中使用,只需添加以下代碼:
<script>
function logichop_monarch_callback (stats) {
console.log( 'logichop_monarch_callback' );
console.log( stats );
// 在這裡添加您的 JavaScript 代碼
}
</script>
當Monarch事件被觸發時會將stats參數發送到logichop_monarch_callback 函数,其值為以下內容:
action
執行的操作。通常是“分享”,“追蹤”或“媒體”。
network
觸發操作的網絡,如“Facebook”,“Twitter”等。
media_url
如果分享的是媒體,則顯示圖像 URL。
post_id
按鈕被觸發的頁面或文章的ID。
想了解 WordPress 的內容個性化嗎?看看我們如何使用Logic Hop的Monarch – 檢查我們的教程:
https://logichop.com/track-social-shares/
外掛標籤
開發者團隊
② 後台搜尋「Callback for Monarch by Logic Hop」→ 直接安裝(推薦)
原文外掛簡介
Callback for Monarch by Logic Hop adds a Javascript callback to the Monarch Social Sharing Plugin. Simply install the plugin and a callback is automatically available when any Monarch social share or follow button is clicked.
Now you can trigger custom events when a social share or follow button has been clicked. The callback is available for use in your pages, posts or Javascript files – Simply add the following code:
When a Monarch event is triggered the stats parameter is sent to the logichop_monarch_callback function with the following values:
action
The action performed. Typically ‘share’, ‘follow’ or ‘media’.
network
The network for which the action was triggered. ‘Facebook’, ‘Twitter’, etc.
media_url
Image URL when media is shared.
post_id
ID of the page or post where the button was triggered.
Interested in Content Personalization for WordPress? See how we’re using Monarch with Logic Hop – Check out our tutorial at: https://logichop.com/track-social-shares/
