Rich-text Reply

Universal Analytics Transaction Discrepancy

michael-v2 05-24-16
Accepted Solution

Universal Analytics Transaction Discrepancy

I've set up Optimizely Universal Analytics and ran an experiment, but I'm getting very disparate numbers for total number of transactions between Google Analytics and Optimizely.

 

Optimizely - Total Transactions
Control - 793 transactions

Variation - 782 transactions

a ~1% loss in total transactions

 

Google Analytics

Control - 708 transactions

Variation - 671 transactions

a ~5% loss in total transactions

 

The code to record a transaction are right next to eachother on the receipt page and surrounded by a test to ensure the customer just purchased and not reviewing a receipt.

 

I've looked for any possible reason for this discrepancy, but am unable to pinpoint it.  It's such a large difference that something must not be correct here. I've looked through the Troubleshooting: Analytics discrepancies, Google Analytics and Universal Analytics, but don't see anything incorrect that I've done.

 

Could someone help me determine the cause?

 

Server Markup Code (Razor C# syntax to generate JavaScript)

 

<script type="text/javascript">
	ga('require', 'ecommerce');
	ga('ecommerce:addTransaction', {
		'id': '@Model.OrderID',                          // Transaction ID. Required
		'affiliation': '@Model.Affiliation',             // Affiliation or store name
		'revenue': '@Model.Order.TotalInUSD',            // Grand Total
		'shipping': '@Model.Order.ShippingAmountInUSD',  // Shipping
		'tax': '@Model.Order.TaxAmountInUSD'             // Tax
	});

	// add item might be called for every item in the shopping cart
	@foreach (var pkg in Model.Order.OrderPackages) {
	<text>
	ga('ecommerce:addItem', {
		'id': '@Model.Order.OrderID',      // Transaction ID. Required
		'name': '@pkg.Name',               // Product name. Required
		'sku': '@pkg.SKU',                 // SKU/code
		'category': '@pkg.ReportCategory', // Category or variation
		'price': '@pkg.PriceInUSD',        // Unit price
		'quantity': '@pkg.Qty'             // Quantity
	});
	</text>
	}

	ga('ecommerce:send');
	window.optimizely = window.optimizely || [];
	window.optimizely.push(['trackEvent', 'purchase', {'revenue': @(Convert.ToInt32(Model.Order.TotalInUSD * 100)) }]);
</script>

 

JasonDahlin 05-24-16
 

Re: Universal Analytics Transaction Discrepancy

Is GA serializing (de-duplicating) your conversions?
That is... if I refresh the order confirmation page, Optimizely would record a second conversion whereas GA may de-duplicate it since it sees that it has already recorded that order id.
--Jason Dahlin
Analytics and Testing Guru Smiley Happy
michael-v2 05-24-16
 

Re: Universal Analytics Transaction Discrepancy

[ Edited ]

Refreshing the page should not cause the transaction to be sent to GA, nor optimizely.  We've tested this scenario.

 

I created a report in GA to view all Transaction IDs and see if any were duplicated and only one transactionID that was reported twice. Every other transaction was only recorded once. So I can tell that GA isn't de-duplicating transactions.

michael-v2 06-01-16
 

Re: Universal Analytics Transaction Discrepancy

I opened a ticket and after back and forth we resolved the issue.  The discrepancy came from the fact that my custom dimension in GA was set to session scope and not user scope.  Optimizely tracks users with a 10 year cookie.  So, if a user sees an experiment, but decides not purchase until the next day, optimizely will count this as a conversion.  Whether or not GA will have the custom dimension marked for this purchase depends on a few factors.

 

Optimizely only sets the GA custom dimension on pages specified in the editor settings' URL Targeting.  So, if a customer returns to the site after the GA session has expired (see How a session is defined in Analytics for more details), but doesn't visit a URL Targeted page, the GA custom dimension will NOT be set.

 

So, you have 2 options

  1. A customer who completes a purchase within a GA session (SESSION SCOPE)
  2. A customer who were included in the variation who complete a purchase eventually (USER SCOPE)

If you decide to use a user scope for your custom dimension you have to realize that if a user who was involved in the first experiment becomes involved in a second experiment, then all future purchases will count towards the second experiment and not the first.

 

Essentially, Optimizely dimensions are set on URL Targeted pages only.  If you use a user scope then any goals made anytime in the future will count towards a conversion for that goal, until the user encounters a new experiment.  Whereas, a session scoped custom dimension will only count as long as the goal is activated within a GA session (30 minutes of inactivity or a day change).

KerriA 10-13-16
 

Re: Universal Analytics Transaction Discrepancy

i was having a similar issue and this was my problem as well. Thanks for posting - I'm sure there are more of us out there!
Level 2