Set custom dimension value only once - google-analytics

Is it possible to create a user or a session level custom dimension whose value only gets set once when the user first lands on the product?
For example, if pages of a product always set a dimension, is it possible to only consider the first value and disregard the rest (the other sets).
Is there something in GA which would enable this or is it left to the developer to write code so that the value is set only once.

Custom Dimensions will always take the most recent value (hit/session/user).
The scope of the dimension depends on the application. If you intend to use the dimension with session level metrics (such as conversion rate) then you will need to set the dimension at session level.
If you are only curious about hit level metrics (time on page, events, page views), then a hit level dimension would be sufficient.
My assumption is that you are curious about the impact that the first interaction has on the resulting user behaviour (and potentially conversion). In this case you will need your developer to set up logic (through cookies or local storage), to only send this value only on the first occurrence. This value should then be saved as a session (or user) level dimension, which you can then use like other session level dimensions such as source/medium, device, etc. Note: if you are setting up a user level dimension, this logic needs to be dictated to your developer to ensure that the logic developed is relevant to your needs.
On a side note, this kind of logic can also be setup through the use of Google Tag Manager, as it allows for the writing of cookies/local storage values, and evaluation of these values.

Related

Read RTK-Query state in a selector without having to pass the cache key

Very simple:
Let’s say we use RTK-Query to retrieve the current weather.
For that, I pass to the endpoint the arg ‘Paris’ as city.
It will serve the current weather of my « game ».
Then later, in a Redux selector, I need to compute some derived state based on that current weather.
How to read the state without having to pass the cache key « Paris »?
Indeed, that knowledge of « Paris » was only necessary at the beginning of the app.
It seems that with RTK-Query we’re stuck since you have to pass the argument that was used (the cache key) to the endpoint#select method.
Am I right in saying that RTK-Query does not currently allow that kind of state reading:
« select that current (and single) store entry X whatever the argument that was needed at loading time is ».
No, since that's an edge case.
Usually, there are multiple cache entries per endpoint, and there is also no concept of a "latest entry" or something, since multiple different components can render at the same time, displaying different entries for the same endpoint - the concept of a "latest" there would come down to pretty random React rendering order.
The most common solution would be to just safe "Paris" somewhere in global state to have it readily available, or to write your selector against RTKQ store internals by hand (although there might be changes to the state internals in the future).

Can you authenticate, then make multiple dependent requests for data using Cloud Firestore?

In my app, a user can log in, then a list of their "pages" (a collection of documents) is retrieved, and their "selectedPageId" is retrieved. This way the UI can show a list of page names, and the content of the selected page.
This means three requests have to happen, each waiting for the other:
log in
get list of pages
get selected page id
Is there a way to make all this happen on the server at once so I can make a single request, which I assume would make my UI render more quickly?
As Dharmaraj mentioned in his comment, "Firebase Auth will still be required on client side". However, is you use the default Auth state persistence (i.e. firebase.auth.Auth.Persistence.LOCAL) once a user is signed in he/she doesn't need to sign in the next times ("the state will be persisted even when the browser window is closed. An explicit sign out is needed to clear that state"). So signing in is not really a problem IMO.
For the Firestore queries: Executing the two queries back-to-back with the second one returning only one document should not take a lot of extra time compare to executing only the first query (which fetches the pages list).
Having said that, one possible approach would be to save, for each user, a Firestore document containing the list of the user's pages plus the user's selectedPageId. You can maintain this page with a Cloud Function which, for example, mirrors the list (documents in a collection) with an array in this Firebase doc. However, you need to take care to not reach the maximum size for a document i.e. 1MiB (hence my question on the number of fields displayed for a page).
One possible variation in this case would be to initially present, in your first app page, a limited number (e.g. 25) of pages of the list, with a "Show more" button.
Finally, note that using a Cloud Function as mentioned in the above comments will very most probably increase the response time compare to standard queries executed via the SDK.

Google Analytics Get Records Where Custom Dimension is Not Set

I'm using Google APIs to retrieve data from Google Analytics with a Custom Dimension. This works well; however, I also have the need to get the data that does NOT have the custom dimension set...
The way's I've seen the Custom Dimension thus far is only to show records where that dimension is set. That makes sense with the domain vocabulary; however, my case and I'm sure others will need access the other slice of the pie.
Is there any way to get a report that includes data with and without the custom dimension being set?
If not is there a way to get a report that contains data that does NOT have the dimension set?
Thanks in advance!
One way would be to report on both cases and then programmatically figure out the exclusion set.
Another (possibly simpler) way would be to always set the custom dimension to a value. The API uses the value (not set) in many dimensions for exactly this purpose. You could instantiate your tracker objects with the custom dimension initially set to (not set) and then reassign when you have a real value. That way all hits would have some value set.
As mentioned by #philip-walton, there is no way to segment on the "not defined" custom dimension bucket (or custom metric for what it's worth).
You could manually set it to (not set) prior to anything else in your code and override them with the right value when the time comes BUT that would be a big problem if you're using session or user level custom dimensions.
The principle of those dimensions is : you set them up once and forget about them.
If you set a session level custom dimension to (not set) on each page prior to sending the hit to GA, you would override this value for all the user's sessions, even for the hits prior to one one you're about to send.
You could initialize the user or session level custom dimension to (not set) but that would require a complex setup using cookies or session storage to remember not to override it if it has been set in your session / user lifetime.
Yeah, unlike adobe analytics which provides a (none) bucket for all cases where a dimension was not set, GA only reports back on the cases where it was set. In the interface you can more readily see % of sessions addressed by the data, but via the API there is no "all other" dimension.
If you give me your precise use case I can try and think of a workaround using segmentation or something else.
Jeff

Designing a web form with default and custom values

The web form I'm working on right now is the electronic version of a contract. The users want to have default values for a large number of the fields to keep wording consistent. However, they also want to be able to enter a custom value or select multiple values for some of the fields. I'm finding that the presentation layer is bleeding into the backend quite heavily and wondering if anyone has some tips on how to go about designing an application like this?
EDIT: I wanted to try and keep from going into the specifics because there is a large amount of business logic in it. But basically I have a form with about 20 fields in it. 3 of the fields have select boxes with multiple options in them. These are the default values I was talking about. But the user also wants to be able to add a "one off" type value to the select. This represents a specific term in the contract that isn't used enough to be valuable as a default. My issue is that I'm storing the default values in the database because the users want to be able to add and remove these defaults at will. Its not just a standard data capture screen.
tblRecord (RecordID, SomeFieldID, CustomText)
tlkpSomeField (SomeFieldID, SomeFieldText)
It sucks, but that is actually a pretty common solution. You can use the CustomText only when the Record shows that SomeFieldID is null. Your data layer will abstract all of that away, so it will be clean. You can also store your default value as the first value in the tlkp table.
tlkpSomeField
1 Default Value
2 value1
3 value2
4 ....
If I understand you correctly, without knowing you or your domain, you have problems with storing both default and chosen value, you sort of get redundant data in the database.
It feels wierd to store the default flag with the chosen item with the freetext when lots of it is just user stuff. Sort of.
My thoughts/recommendations are:
Default value doesn't have any business value so don't store it as users' choice. Just store what the user chose/freetext.
Or does it Mean something that the user chose default? Then there is business value to it and you should store the value/text the user chose and a tick that it happened to be the default value.
Or I might have misunderstood you totally...

How to manage complex data entry validation

I feel like I am fighting against the current when I develop ASP.NET Webform apps. I frequently run into the same problems, and while I eventually find some kind of workaround i'm never fully satisfied with the results.
Here is an example of a typical problem:
The design requires a grid or grid-like result set. This result set is pulled from a database, however, there are additional controls on each row that are not data bound, but their contents are used to insert data into other records.
A good example of this would be displaying a list of products, then adding selected products to a shopping cart based on values entered into quantity fields, and options selected per product. Throw into the mix that you have to allow multiple lines to be added to the cart at the same time, and it starts to get more complex.
Let's add to that mix that you can't select certain products together (mutually exclusive), that you can only select a certain number of one product, but not another, that prices may change while the user is selecting their items, that you you get an overall discount per item based on quantity purchased (both per item and overall order), that you are using a line of credit and cannot exceed the line of credit, nor can you buy more of a given item than an arbitrary amount set in your account or in the product by your account representitive (think certain over the counter medications that the government limits how many you can buy), etc.. etc.. etc..
What starts out as a simple grid with an add to cart becomes a hopeless mess of business logic, which then of course requires validation and notification to the user of various errors in their choices.
How does one deal with very complex data entry schemes in asp.net? How do you even begin to design a piece of software to do all this?
EDIT:
Please don't suggest changing the interface, as the interface is not the problem. Users are fine with it, and they demand that it function the way it does. I'm looking for help on how to design and solve the problem of implementing it.
Don't put anything other than the basic validation in your code behind. The code behind should just take what the user entered, build a business object (or collection of business objects) and let those business objects validate themselves.
Each business rule should be a single function call on the business object that deals with just the one rule and nothing else. You then simply call them one after another and keep track of which ones pass and which ones fail.
When a validation fails, the business objects can provide the code behind enough information that it can display the correct errors and highlight the fields that have errors.
Some options to consider:
Separate out your validation logic so you can call it from both client-side and server-side code (enables next point).
Use AJAX to perform server-side validation and provide immediate feedback as the user performs various tasks, ie increases quantity.
Provide abundant and clear instructions/feedback to the user both before and after any actions are performed. Before: warn that product X can't be bought with product Y (especially if Y is already in the cart). After: explain the problem exactly and suggest ways to correct, eg "why don't you remove product Y?")
Fail gracefully, ie if only one product fails validation then ensure all other products are added.
Simplify the entry process, eg only allow one product to be added to the cart at a time.
The last point is important. A complicated data entry process can confuse users before they start, and makes trying to understand the numerous validation errors difficult. And this is even before you start coding the validation logic.

Resources