简体   繁体   English

onclick 链接触发谷歌分析 gtag

[英]onclick link fires google analytics gtag

what could be the problem why onclick does not fire the gtag.为什么 onclick 不触发 gtag 可能是什么问题。 I tried all variantions of quotes.我尝试了引号的所有变体。

<a href="https://www.site.de/analytics.php?page=1&del=TR-123" onclick="gtag('event', 'refund', {
  'transaction_id': 'TR-123',
  'value': 90.17, 
  'currency': 'USD',
  'items': [{
      'id': '402',
      'name': 'Diamant 050-029-034 comfort',
      'quantity': 1,
      'price': '90.17'
    }]
});">

Where do I have to use "" and where '我必须在哪里使用 "" 以及在哪里 '

I think the issue is that this onclick is on a hyperlink.我认为问题在于这个 onclick 在超链接上。

<a href="https://www.site.de/analytics.php?page=1&del=TR-123" onclick="javascript:(function() { 
gtag('event', 'refund', {
  'transaction_id': 'TR-123',
  'value': 90.17, 
  'currency': 'USD',
  'items': [{
      'id': '402',
      'name': 'Diamant 050-029-034 comfort',
      'quantity': 1,
      'price': '90.17'
    }]
});
return false;
); })()">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM