Pat*_*nny 6 google-analytics google-analytics-4
我正在尝试使用 Google Analytics 4 来跟踪 Stripe 的付款错误。
我正在使用 Drupal 8;这是相关的JS:
// Helper to handle the Stripe responses with errors.
var stripeErrorHandler = function (result) {
if (result.error) {
// Inform the user if there was an error.
// Display the message error in the payment form.
Drupal.commerceStripe.displayError(result.error.message);
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('event', 'exception', {
'description': result.error.message,
'fatal': false
});
// Allow the customer to re-submit the form.
$form.find(':input.button--primary').prop('disabled', false);
}
Run Code Online (Sandbox Code Playgroud)
该gtag()函数取自Google 开发者文档,用于在 GA4 中推送异常。
我在 Analytics 中打开调试模式,转到结帐页面,然后输入无效的到期日期。
在 Chrome 开发控制台中,我可以看到记录了异常:
Processing GTAG command: ["event", "exception", {description: "Your card has expired.", fatal: false}]
Run Code Online (Sandbox Code Playgroud)
但是,异常实际上并未记录在 Analytics 中。我还需要做什么才能记录异常?
| 归档时间: |
|
| 查看次数: |
628 次 |
| 最近记录: |