Analytics
2.9K members online now
2.9K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Google analytics not recording data for certain users #API's

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I am tracking the performance of my web application using google's User Timing API. I have the following code in my javascript file which measures the performance of the request and send collective data to Google. 

 

My logic determines selective AJAX request from gaTracking object and measures the performance for that request and send collective data to Analytics.

 

gaTracking = {
"api/v1/products?action1=filter" : {
"timingCategory" : "Orders",
"timingVar" : "Cart",
"timingLabel" : "Simple Order All Products"
},
"api/v1/cart?action1=simpleadd" : {
"timingCategory" : "Orders",
"timingVar" : "Cart",
"timingLabel" : "Simple Add To Cart"
},
"api/v1/cart?action1=simpleupdate" : {
"timingCategory" : "Orders",
"timingVar" : "Cart",
"timingLabel" : "Simple Edit Cart"
},
"api/v1/cart" : {
"timingCategory" : "Orders",
"timingVar" : "Cart",
"timingLabel" : "Loading Cart Items"
},
"api/v1/cart?action1=complete" : {
"timingCategory" : "Orders",
"timingVar" : "Cart",
"timingLabel" : "Submit Order"
}
};
if(!!options.pageType) {
options.url += '&pagetype=' + options.pageType;
}
matchVal = _.filter(gaTracking, function (val, key) {
var bool = (key === options.url.toLowerCase()) ? true : false;
if(bool) {
group = val;
return true;
}
});
if(!!matchVal.length) {
return $.ajax( $.extend({
beforeSend: function ( xhr ) {
startDate = new Date();
startTime = new Date().getTime();
}
}, params, options ) ).done (function (data, textStatus, jqXHR) {
try {
order = Wave.Order.get();
if(group.timingVar === "Cart" && !!data[0] && !!data[0].CART && !!data[0].CART.TRX_ID) {
trxId = data[0].CART.TRX_ID;
timingVble = group.timingVar + '-' + trxId;
}
else if( !!order.TRX_ID ) { // This condition is check for filters because filters XML doesn't have TRX_ID
trxId = order.TRX_ID;
timingVble = group.timingVar + '-' + trxId;
}
else { timingVble = group.timingVar; }
//timingVble = startDate + '-' + timingVble;
timingLbl = (!!data[0].SEARCHTYPE) ? startDate + '-' + data[0].SEARCHTYPE : startDate + '-' + group.timingLabel;
totalTime = new Date().getTime() - startTime;
// for troubleshooting
var groupTest = { timingCategory: group.timingCategory, timingVar: timingVble, timingLabel: timingLbl};
console.log("Sending.. ", groupTest);
ga('send', 'timing', group.timingCategory, timingVble, totalTime, timingLbl);
}
catch (e) {
if ('console' in window && !!console.log) {
console.log('Google Analytics: ', e);
}
}
});
}
else {
return $.ajax( $.extend( params, options ) );
}

 

This code only tracks this requests only for certain users. For example out of 300 sales reps using the system it only records this data for 170 sales reps. Why is it not reporting data for other users?

 

Thanks,

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Key T
April 2016

Re: Google analytics not recording data for certain users #API's

Rising Star
# 2
Rising Star
Hi Key,

User timings are subject to sampled collection.

"Sampling considerations

Google Analytics will sample timing hits during processing in order to ensure an equitable distribution of system resources for this feature.

The rate at which timing hits are sampled is determined by the total number of pageview hits received during the previous day for the property."

See more here:

https://developers.google.com/analytics/devguides/collection/analyticsjs/user-timings#sampling_consi...

Best,

Theo Bennett
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Key T
April 2016

Re: Google analytics not recording data for certain users #API's

Rising Star
# 2
Rising Star
Hi Key,

User timings are subject to sampled collection.

"Sampling considerations

Google Analytics will sample timing hits during processing in order to ensure an equitable distribution of system resources for this feature.

The rate at which timing hits are sampled is determined by the total number of pageview hits received during the previous day for the property."

See more here:

https://developers.google.com/analytics/devguides/collection/analyticsjs/user-timings#sampling_consi...

Best,

Theo Bennett
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn