I'm having a hard time finding clear documentation on how to handle this situation and what best practise is.

How off is my implementation and what steps should I take to fix it? Will it count as two pageviews? Do I need the second pageview?

I my head

  // analytics.js

  ga('create', 'UA-XXXXXXXX-XX', 'auto');
  ga('require', 'ec');
  ga('set', 'dimension1', 'somevalue')
  ga('set', 'dimension2', 'somevalue')
  ga('send', 'pageview');

on pageload in checkout

for (var i = 0; i < cart.products.length; i++) {
  var product = cart.products[i];

  const gaProductObject = {
    'id': product.id,
    'name': product.name,
    'category': product.category
    'price': product.price,
    'quantity': product.quantity,
    'brand': product.brand
  ga('ec:addProduct', gaProductObject)

if (this.user.isAuthenticated) {
  ga('ec:setAction', 'checkout', {
    'step': 2,
    'option': null
} else {
  ga('ec:setAction', 'checkout', {
    'step': 1,
    'option': null

ga('set', 'dimension1', this.user.market)
ga('set', 'dimension2', this.user.language)
ga('send', 'event', 'checkout', 'view')
ga('send', 'pageview')

Using: GA and Enhanced Ecommerce.
Site: hybrid .NET and Vue. No Virtual Views required page do pageloads on each navigation.

Thankful for feedback.

  • I'm not familiar enough with direct ga() setup to write this as an answer, but my assessment would be a) yes, you'd see two pageview hits, and b) no, you shouldn't need the second pageview because the event hit will include page and custom dimension data. For session-scope dimensions, the last value sent in the session will be the value associated to all hits of the session. – Reve Nov 18 at 16:29
  • @Reve thanks for the reply. Yes I figured it out. I'm not using session based. – Dejan.S Nov 19 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.