链接跟踪器的工作原理
链接跟踪器是一个选项,允许您创建自定义跟踪链接,将数据发送到您的跟踪系统。在此示例中,我们使用 Google Analytics(分析)来跟踪 PayPal 中发生的转化。这是一个基于cookie的电子商务事件。这种类型的事件仅发送一次数据,第一次执行时创建唯一事件,然后重定向到目标链接(在我们的示例中为 PayPal 发票)。将日期发送到 Google Analytics API 后,即使多次点击链接,它也会忽略新的点击,从而避免在您的 Google Analytics 帐户中重复数据。
事件剖析:
1. 我们创建了一种特殊类型的事件,将事件特征与特定于电子商务产品的事件特征相结合。
代码: 全选
'event', // Sends your conversion as an Event with the "ecommerce" "category" in your GA events reports
'purchase', // Specifies the "action" of the event
{
'event_label': 'NAMEIT', // This is the "label" of the event. You can rename. (e.g. Plan2)
'transaction_id': 'INVOICE NUMBER', // This is the ID of conversion. (e.g. 634)
'value': XXX.00, // Specifies the total revenue or grand total associated with the transaction (e.g. 11.99)
'currency': "XXX", // Local currency code. (e.g USD)
'tax': 0.0, // Specifies the total shipping cost of the transaction. (e.g. 5)
'shipping': 0, // Specifies the total tax of the transaction. (e.g. 1.29)
2. 接下来,HTML 代码的第二部分将交易详细信息发送到您的 Google Analytics 帐户。
代码: 全选
"items": [
{
"id": "YourPlanID", // Transaction ID. For this specific case it's SKU. Required.
"name": "NameIt", // Product name. Required.
"quantity": XX, // Quantity. Required.
"price": "XX.0" // Price per Unit. Required.
}]
您可以在 Google Analytics(分析)帐户中找到有关产品效果报告的第二组数据。
3. 代码的最后一部分在收到来自 Google Analytics API 的响应后,向目标链接发出重定向请求。这是必需的。
代码: 全选
'event_callback': function() {
redirect(1000);
}
转到 tagDiv Opt-In Builder > Link Tracker 并添加以下信息:
1. 输入要重定向到的 URL。
2. 为新模板命名
3. 粘贴 HTML 脚本,并通过更改事务 ID、值等来自定义它。
4. 如果您已经保存了许多脚本模板,请从页面 HTML 保存的模板下拉列表中选择所需的模板并对其进行自定义。
5. 保存以备后用
6. 如果您想在 Link Tracker 仪表板中显示特定内容以帮助您识别特定链接,请写一个注释。
7. 复制链接并将其发送给您的客户
根据需要创建任意数量的跟踪代码。
将 HTML 脚本另存为模板,以便以后使用。
在 Link Tracker 仪表板中,您可以查看点击计数、查看、编辑或删除脚本模板。
您可以使用此代码作为参考:
代码: 全选
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxx"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag( 'js', new Date() );
gtag( 'config', 'UA-xxxxxxxx-x' );
gtag(
'event',
'purchase',
{
'event_label': 'NAMEIT',
'transaction_id': 'INVOICE NUMBER',
'value': XXX.00,
'currency': "XXX",
'tax': 0.0,
'shipping': 0,
"items": [
{
"id": "Your Plan ID",
"name": "NameIt",
"quantity": XX,
"price": "XX.0"
},
{
"id": "Your Plan ID1",
"name": "NameIt1",
"quantity": XX,
"price": "XX.0"
},
],
'event_callback': function() {
redirect(1000);
}
}
);
</script>