Answer the question
In order to leave comments, you need to log in
How to remove the Uncaught ReferenceError error?
I understand the technology of transferring data to analytics, I sketched out the code, but it gives an error:
I duplicate all messages from the console here, the error is in the third message
Chrome is blocking ads on this site because this site tends to show ads that interrupt, distract, or prevent user control. You should fix the issues as soon as possible and submit your site for another review. Learn more at https://www.chromestatus.com/feature/5738264052891648
Conflict when accessing the jQuery Mask Input Plugin: undefined typeof $.mask
Uncaught ReferenceError : onAjaxSuccess is not defined at HTMLAnchorElement.- points to the first onAjaxSuccess in the code.
<a id='buttonId'>отправить данные в аналитику</a>
<script>
$('#buttonId').click(function(){
$.post(
"http://www.google-analytics.com/collect",
{
v: '1',
tid: 'UA-xxxxxx-1',
cid: 'a7a364d8-0d14-4e77-b637-xxxxxxxxxx',
t: 'transaction',
ti: '21001',
ta: 'online покупка',
tr: '1000.00'
},
onAjaxSuccess
)
$.post(
"http://www.google-analytics.com/collect",
{
v: '1',
tid: 'UA-xxxxxx-1',
cid: 'a7a364d8-0d14-4e77-b637-xxxxxxxxxx',
t: 'item',
ti: '21001',
in: 'товар1',
ip: '700.00',
iv: 'категория1'
},
onAjaxSuccess
)
$.post(
"http://www.google-analytics.com/collect",
{
v: '1',
tid: 'UA-xxxxxx-1',
cid: 'a7a364d8-0d14-4e77-b637-xxxxxxxxxx',
t: 'item',
ti: '21001',
in: 'товар2',
ip: '300.00',
iv: 'категория2'
},
onAjaxSuccess
)
});
</script>
Answer the question
In order to leave comments, you need to log in
You are using an undefined identifier onAjaxSucces in your code and you are getting the corresponding error.
You must define the onAjaxSucces function in the code above.
function onAjaxSucces(data) {
// do something with data
}
$.post(
"http://www.google-analytics.com/collect",
{
v: '1',
tid: 'UA-xxxxxx-1',
cid: 'a7a364d8-0d14-4e77-b637-xxxxxxxxxx',
t: 'item',
ti: '21001',
in: 'товар2',
ip: '300.00',
iv: 'категория2'
},
onAjaxSucces
);
$.post(
"http://www.google-analytics.com/collect",
{
v: '1',
tid: 'UA-xxxxxx-1',
cid: 'a7a364d8-0d14-4e77-b637-xxxxxxxxxx',
t: 'item',
ti: '21001',
in: 'товар2',
ip: '300.00',
iv: 'категория2'
},
function(data) {
// do something with data
}
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question