9

I'm trying to implement product impressions on a ecommerce catalog page using google analytics enhanced ecommerce tracking.

Following the specs one should implement it like this:

ga('create', 'UA-XXXXX-Y');
ga('require', 'ec');

ga('ec:addImpression', {
  'id': 'P12345',                   // Product details are provided in an impressionFieldObject.
  'name': 'Android Warhol T-Shirt',
  'category': 'Apparel/T-Shirts',
  'brand': 'Google',
  'variant': 'black',
  'list': 'Search Results',
  'position': 1                     // 'position' indicates the product position in the list.
});

ga('ec:addImpression', {
  'id': 'P67890',
  'name': 'YouTube Organic T-Shirt',
  'type': 'view',
  'category': 'Apparel/T-Shirts',
  'brand': , 'YouTube',
  'variant': 'gray',
  'list': 'Search Results',
  'position': 2
});

ga('send', 'pageview');              // Send product impressions with initial pageview.

Although the specs show a track pageview event. In order to send REAL impressions I wanted to trigger the beacon once the user scrolled down. To do that I've triggered the event through a "lazy loader" which loads gradually the images on the catalog using the event 'ga(send, impression)' but it won't work and if I do that with additional pageviews events I would be corrupting my pageviews metric on GA.

Does anyone have ideas on how to solve that?

cmotta
  • 95
  • 1
  • 5

1 Answers1

17

From the Enhanced Ecommerce docs:

Note: Ecommerce data can only be sent with an existing hit, for example a pageview or event. If you use ecommerce commands but do not send any hits, or the hit is sent before the ecommerce command then the ecommerce data will not be sent.

Send it with a non-interactive event instead:

ga('send', 'event', 'catalog', 'impression', {'nonInteraction': true});

cmotta
  • 95
  • 1
  • 5
Blexy
  • 9,573
  • 6
  • 42
  • 55
  • 1
    Thanks blexy. Just to improve your answer, i'll edit the code to camel case and boolean as the analytics debugger raised these flags. – cmotta Aug 08 '14 at 02:59
  • I'm a little confused by this answer as it doesn't include the object anywhere in the send event. How does sending the event pick up the impression data, and if it grabs it from the browser, how do you prevent it from re-sending impression data that may have been from a previous scroll event? – James Oct 31 '14 at 05:08
  • 1
    @James I know its a bit late, but I arrived here with the same issue. The answer is to first register the impression as usual via ga('ec:addImpression...), then to use the above code on the next line. I saw that here: https://productforums.google.com/d/msg/analytics/LCvi94Pu4MA/UvpLzeCc0a4J – ethanpil Jul 09 '15 at 17:56