The consulting and engineering teams at E-Nor continue to take advantage of Measurement Protocol to meet a range of tracking needs that our clients bring to us. We also continue to discuss critical Measurement Protocol concepts on our blog so you can get closer to a universal understanding of user engagement, even when the tracking context presents specific challenges, such as limited connectivity for mobile app users (think cruise ship…).
Validate Measurement Protocol Hits Using Google oauth Playground
You may have already had the chance to reference our Measurement Protocol Parameter Reference for required and optional parameters in a Measurement Protocol hit, but how can you actually verify that your Measurement Protocol hits are well-formed as you’re writing them into your coding logic?
Use the Google OAuth 2.0 Playground to validate any HTTP request, including the measurement protocol hits. Google OAuth Playground will validate if the hit is valid or not. A hit is valid if:
- it has the minimum number of parameters.
- all parameters are included in the right format.
Very easy to use, the Google OAuth Playground confirms and reports all the needed information about the hit, including extra details that could be helpful for developers, including request headers and get or post request method.
To validate a Measurement Protocol hit using Google OAuth Playground:
- Open Google OAuth 2.0 Playground.
- Choose the API you want to use (Google Analytics in our case) and click Authorize APIs.
- Ignore step #2 and move directly to step #3 (Configure request to API).
- In the Request URI field, add this sample hit and send the request:The response will indicate that the request was not valid.
We forgot to specify a valid tid parameter, that is, a Google Analytics property ID. Let’s try again with a valid tid parameter:
Queue Time Parameter for More Accurate Offline Interaction Timestamping
Another of our previous blog posts considered Integrating the User Journey with Google Analytics: Three Offline Business Cases. What about a tracking scenario that is offline in the sense that the user is interacting with a mobile app on a device that may be suffering from spotty internet access?
Queue Time (qt) is an optional parameter, but it can be really useful for the purposes of:
- recording hits with the time at which they actually occurred if the sending of the hit has to be delayed.
- ordering hits.
Queue Time can be critical for reliable tracking in that mobile app scenario (if you’re using Measurement Protocol to track a non-iOS or non-Android mobile app, for example). As a few specific considerations for queue time:
- You provide the time delta in milliseconds.
- The value must be greater than or equal to 0.
- Values greater than four hours may lead to hits not being processed. This is the most important point, as you could lose a significant amount of data if you set the queue time for more than four hours.
Also, using the Google Analytics batch (https://www.google-analytics.com/batch) endpoint, instead of the collect (https://www.google-analytics.com/collect) endpoint, in addition to the Queue Time parameter, will give more control over the sending order because you can send up to 20 hits at a time per batch request with 16k bytes as maximum payload.
One challenge that the E-Nor engineering team faced was tracking user interaction with an app that was likely to be used aboard ships.
The tracking steps included:
- Check for connectivity.
- If connectivity is good, send a Measurement Protocol hit without the queue time parameter.
- If connectivity is not good, store the user interaction locally (as XML, or with any suitable persistence mechanism), making sure to save the timestamp at which the interaction actually occurred.
- Recheck for connectivity at regular intervals.
- If connectivity is good, send a Measurement Protocol hit with the qt parameter representing the difference in milliseconds between the time the timestamp of the user interaction and the time the hit is sent.
For instance, the Measurement Protocol hit below would record a user interaction as having occurred 88 minutes – or 5,280,000 milliseconds – before the time of good connectivity at which the hit is sent:
Have questions about measurement strategy? Contact us today.
About the Author
Analytics Consultant - Implementation
An enthusiastic advocate for “Work harder but smarter”, Morsi believes that there is always a solution for any dilemma, “Whatever it takes” is his go-to response in any challenge. Java certified, holding a CIW Master degree in Web Design and 10+ years of extensive experience in web development, UI and usability. In addition to Google Analytics and Google Analytics APIs, Morsi delivers unique exquisite solutions to our client’s needs.