如何通过Javascript从Google分析功能访问信息
我的客户在他的网站上有Google Analytics,当客户到达感谢页面时,它会记录客户购买了什么 我需要获取产品ID,并将其放入一个变量中,用于facebook跟踪 我可以通过GTM访问,但不能接触实际的源代码 感谢页面上的Google Analytics如下所示:如何通过Javascript从Google分析功能访问信息,javascript,google-analytics,google-tag-manager,facebook-pixel,Javascript,Google Analytics,Google Tag Manager,Facebook Pixel,我的客户在他的网站上有Google Analytics,当客户到达感谢页面时,它会记录客户购买了什么 我需要获取产品ID,并将其放入一个变量中,用于facebook跟踪 我可以通过GTM访问,但不能接触实际的源代码 感谢页面上的Google Analytics如下所示: <script type="text/javascript"> // Order Complet GA ga('ec:setAction','checkout', { 'step': 6, }); ga(
<script type="text/javascript">
// Order Complet GA
ga('ec:setAction','checkout', {
'step': 6,
});
ga('set', '&cu', 'EUR');
ga('ec:addProduct',{
'id': '44',
'name': 'Zeobent MED® Detox-Pulver ultrafein 210g für 70 Tage',
'category': 'Zeobent',
'brand': 'Zeobent MED',
'price': '39.00',
'quantity': 1
});
ga('ec:setAction', 'purchase', {
id: '100120166',
affiliation: 'ZeolithShop',
revenue: '44.90',
tax: '6.23',
shipping: '5.90',
coupon: ''
});
//Auskommentiert weil Doppeltausgel�st 31.01.17 Tina SWA - ga('send', 'pageview', '/checkout-success');
//全序遗传算法
ga('ec:setAction','checkout'{
“步骤”:6,
});
ga(‘集合’、‘cu’、‘EUR’);
ga('ec:addProduct',{
“id”:“44”,
“名称”:“Zeobent MED®解毒脉冲超飞210g für 70 Tage”,
“类别”:“Zeobent”,
“品牌”:“Zeobent MED”,
‘价格’:‘39.00’,
“数量”:1
});
ga('ec:setAction'、'purchase'{
id:'100120166',
隶属关系:“ZeolithShop”,
收入:'44.90',
税:'6.23',
航运:'5.90',
优惠券:“”
});
//奥斯克蒙蒂埃·威尔·多佩尔塔斯格尔酒店�st 31.01.17 Tina SWA-ga(“发送”、“页面浏览”、“签出成功”);
如何访问ec:addProduct
中的id
中的内容
此代码在“谢谢”页面加载后立即生成
没有数据层。您可以这样访问它:
var matches = $('script:contains("ec:addProduct")').text().match(/'ec\:addProduct'\,{[ \n]+'id': '(.*?)'\,[ \n]+'name': '(.*?)'/);
if (matches != null && matches.length>=3)
{
var id = matches[1];
var name = matches[2];
}