【发布时间】:2019-07-22 03:57:02
【问题描述】:
我有一个基本上看起来像这样的脚本:
<script>
// Send transaction data with a pageview if available
// when the page loads. Otherwise, use an event when the transaction
// data becomes available.
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': 'T12345', // Transaction ID. Required for purchases and refunds.
'affiliation': 'Online Store',
'revenue': '35.43', // Total transaction value (incl. tax and shipping)
'tax':'4.90',
'shipping': '5.99',
'coupon': 'SUMMER_SALE'
},
'products': [{ // List of productFieldObjects.
'name': 'Triblend Android T-Shirt', // Name or ID is required.
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1,
'coupon': '' // Optional fields may be omitted or set to empty string.
},
{
'name': 'Donut Friday Scented T-Shirt',
'id': '67890',
'price': '33.75',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Black',
'quantity': 1
}]
}
}
});
</script>
基本上我需要在我的代码中执行这个脚本,该脚本将由计划任务每 xx 小时(可能每 4 小时)触发一次。
API 链接:
https://developers.google.com/tag-manager/enhanced-ecommerce#purchases
我感兴趣的部分是:
衡量购买
基本上,因为我找不到任何类型的 c# 或 PHP 实现,所以我决定走这条路线,在后台执行 javascript...
我认为它可能是什么样子:
private void ExecuteMyScript(){
// Now to execute the script above ...
}
此方法将由计划任务每 4 小时触发一次。
这在 .NET MVC 中可行吗?这是我第一次遇到这样的事情,所以非常欢迎所有帮助和建议。
【问题讨论】:
标签: javascript c# asp.net asp.net-mvc asp.net-mvc-4