使用Bootstrap Notify使用Google Analytics(分析)方法呈现按钮

时间:2018-07-18 11:06:33

标签: javascript google-analytics bootstrap-notify

我想跟踪有多少用户使用Google Analytics(分析)单击某个链接。我正在使用Bootstrap通知,这是完成的过程:

                $.notify({
                    icon: 'images/icon/donation.svg',
                    title: 'Dukung Indorelawan.org untuk semakin berkembang!',
                    message: 'Bantu kami menghubungkan lebih banyak lagi aksi baik dengan berdonasi untuk Indorelawan',
                    url: 'https://www.indorelawan.org/donation' 
                    },
                    {
                        type: 'minimalist',
                        icon_type: 'image',
                        placement: {
                            from: "bottom",
                            align: "right"
                        },
                        delay: 0,
                        animate: {
                            enter: 'animated slideInRight',
                            exit: 'animated slideOutRight'
                        },
                        url_target: '_blank',
                        template: '<div data-notify="container" class="col-xs-11 col-sm-6 col-md-4 alert alert-{0} clearfix" role="alert">' +
                            '<button type="button" aria-hidden="true" class="close pull-right" data-notify="dismiss" onclick="ga("send","event","detail-activity", "click-name", "donation-popup-closed");">x</button>' + 
                            '<img data-notify="icon" class=" pull-left" align="left">' +
                            '<p class="clearfix"><span data-notify="title">{1}</span>' +
                            '<span data-notify="message">{2} <a href="/donation" onclick="ga("send","event","detail-activity", "click-name", "donation-popup");" target="_blank">di sini!</a></span></p>' +
                        '</div>'
                });

如您所见,有一些onclick方法,例如 onclick =“ ga(” send“,” event“,” detail-activity“,” click-name“,” donation-popup-closed“ );“ 。它可以正常显示,但是当我单击链接时,没有任何数据提交到Google Analytics(分析)。因为在控制台中存在错误:

  

未捕获到的SyntaxError:输入意外结束

我使用了“检查元素”来找出来源,结果是这样的:

<button type="button" aria-hidden="true" class="close pull-right" data-notify="dismiss" onclick="ga(" send","event","detail-activity",="" "click-name",="" "donation-popup-closed");"="" style="position: absolute; right: 10px; top: 5px; z-index: 1033;">x</button>

有什么解决方法吗?

0 个答案:

没有答案