K
K
KirillMilano2015-03-05 11:58:15
JavaScript
KirillMilano, 2015-03-05 11:58:15

Setting up Google Analytics Ecommerce for AJAX?

I set up GA statistics in the store. In this case, I ran into the same problem. There is a product page. 12 products are displayed on 1 screen. Further, when scrolling, the list of goods is loaded automatically on AJAX. With the registration of the first list of goods, everything is clear and simple. The following code is executed in HEAD:

<script type="text/javascript">
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'XXX', 'auto');
  ga('require', 'ec');
  ga('ec:addImpression', {"id":"3178","name":"Iphone 5S","list":"Shop main, recommend","position":1});
  ga('ec:addImpression', {"id":"3182","name":"Iphone 5","list":"Shop main, recommend","position":2});
  
  ga('send', 'pageview');
</script>


But after loading a new portion of goods, I also need to register them using ec: addImpression and send the data to the Google server. How can I do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Tsyplakov, 2015-03-05
@grimich

You can also collect the impression in a bundle and send it to GA through a non-interaction event upon loading each piece

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question