简体   繁体   中英

onclick link fires google analytics gtag

what could be the problem why onclick does not fire the 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.

<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;
); })()">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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