I need to manually override the value that Google analytics sends for the deviceCategory predefined user dimension (let's say that instead of "mobile", I need It to be "android phone"). But I couldn't find anywhere in the SDK documentation if this is possible or not, and how to do it, other than using a custom dimension, which is not what I want.
Is this even possible?
You can definitely override some of the default dimensions as shown here You could probably follow the same algo to override other dimensions.
Another thing I'd try is looking at the network request and seeing if deviceCategory can be overriden by setting it as an event propery.
Finally, you can always override any field if you use GTM inbetween, but it's kind of an overkill. You don't want to use it just to slightly shift the field value.
I would generally suggest either not touching it at all if you're just renaming it for the comfort of the analyst or using a custom dimension/event propery to track it if it's a separate datapoint.
Related
There are scenarios in feature files wherein I've use the text "Foo" and on click its open a new page. this text sometime changes to "Foo1" or "Foo2" or to something else. to avoid line by line change in feature file for "Foo" to "Foo1" or "Foo2" is there any way that I can globally declare variable in top/bottom of the feature file where I can set the required text in variable on fly and I shall start executing my test instantly?
This change exist in many feature files and around 1000 lines in feature file. To get solution for this, I try on setting environment variables but I couldn't reach all the way till end this issue to solve. So can anyone help me on this?
Thanks in advance
What if you do the replacement in your step implementation instead? Then you could have the desired value in a separate file or pass it as arguments. That way you don't need to hard code the values.
Could scenario outlines help you in any way or is the value only changing depending on external changes?
My first thought was scenario outlines like #homaxto said.
Then I thought you might want to affect it by which system you are connected to. You can do this through configuration. I have done this with Fig_Newton.
You can either set an environment varaible or use one in the commandline. Or you can use #hook type tags. With a hook tag, you can have a tag at the top of a feature file that you can use to set a variable that affects how the steps operate (but it needs to be handled inside the step).
How can I attach a custom metric value to HitBuilders.TransactionBuilder in the following fashion? I want to associate a transaction with a value.
tracker.send(new HitBuilders.TransactionBuilder()
.setOtherAttributes(...)
.setCustomMetric(1, 10)
.build());
The rest of the data are successfully sent, but the custom metric is always 0.
It seems your code is correct. You can try to setCustomDimension instead of setCustomMetric, you only have to transform float to string.
Your code is correct. What you need to check is the server side reports you build.
Make sure you created a Custom metric in Admin - Custom Definitions - Custom metrics. Once created, custom metrics will initially appear with a 3 to 4 hours delay on the server. Give them some time to appear there. Finally, you need to create a report to see the result. Make sure you choose the right time intervals and don't add too many metric and filters, otherwise you won't see data. Make first reposts as simple as possible. I hope this helps.
The problem was with that the scope of the custom metric was not Hit and that I was looking at a custom report widget matched by Product. The value appeared when I changed the column.
My requirement is to put in a place name in a text field and show that in the map, so i used geocomplete js, which works well.
Now my user should be able to put in user defined places like 'my house', for that I need to remove the geocomplete on clicking a 'x' button on top of the map.
How can I implement this?
Thanks in advance
I wouldn't customize the package! When a new version comes out, you'll have to make the same changes you before.
Since you haven't provided any code, I can give you an idea of what I've done with JQuery validation method overrides.
You'll simply have to find the listener (something like $('#listenToThis').on('click', function(){ doThings(); }) in the geocomplete.js file, then override it in a file that is included after geocomplete.
If you're using bundles, just include your file after the geocomplete listener response is defined.
So, after you find those, you can do something similar to the following:
$.validator.methods.number = function (value, element) {
value = floatValue(value);
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:[\s\.,]\d{3})+)(?:[\.,]\d+)?$/.test(value);
}
The function above allowed me to validate client-side numbers that were formatted as currency in JQuery ($).
This overrides the JQuery.validator.methods.number function (a cheating way to override the function without changing the package code), so if you can pinpoint the geocomplete.addSomethingToMap or geocomplete.reactToClick function, you should override it and it will essentially work that way.
Warning, though: you will need to reinclude the changes when you want to reenable the feature. You'll have to override, override, override again. This may not be the best way if they're going to be adding hundreds of different new locations on one screen, but for up to a small unit, such as a dozen, it should be a good solution.
Is there any way to intercept the Android framework's inflation of xml resources (menus and layouts) to change the strings it uses (e.g. for attributes like android:text="#string/button_trade_commit".)
I know it's possible to override getString() as it's called from an Activity. But framework code doesn't seem to use getString(). For example, in MenuInflator.java, strings come from mContext.obtainStyledAttributes(), and obtainStyledAttributes() is final: I can't override it.
Anybody know of another way to accomplish this?
Background: I want to allow non-English-speaking users to localize my app themselves. I imagine an interface that displays the English strings and lets them enter a translation which is then used in place of the English string from then on. I can imagine also providing a "Share translations" button that uploads the translations, and then,
on the server side, incorporating them into a downloadable module that other users of the same language would get. Being able to substitute strings at runtime is the blocking piece that I can't figure out.
I don't believe you can override the systems getString() methods the way you are looking at it.
It might be worth trying to use a custom attribute and handle the work there: http://developer.android.com/training/custom-views/create-view.html#customattr
I don't think you will be able to modify the process Android uses when inflating resources the way you wanted to.
What you can do is to simply not provide any strings (android:text, etc.) in XML files. You can always obtain a reference to any element in your XML file in the code. Once you have a reference, you can provide texts in the code, taking properly localized strings from your custom framework.
I am not sure about this, but i think you can examine the source of Calligraphy library for Android. It is overriding system LayoutInflater to change the FontType, so i imagine you can do the same to change the strings.
I have a view that displays all the levels of my game. These levels are read by the activity and then passed into the view. I could read them from the view, but it's not really its responsibility, and I'm a fan of separation of concerns.
Right now, I'm calling a setter for this:
((GameView) findViewById(R.id.game)).setLevels(loadLevels());
However, I don't like the fact that the view will be dysfunctional if I forget to call the setter. Is there a better way to pass the levels in?
It is also a bit a matter of preference. Theoretically it's perfectly fine to pass the levels as you're doing. Alternatively, if you need more than just set the levels, but provide further functionalities (i.e. also saving of levels) I normally use a separate class responsible for handling such things (i.e. a Repository, some "Manager" class etc...). This class is then passed into the View on the constructor preferably s.t. one is forced to provide it. Of course, in order to separate things, I use interfaces rather than specific implementations s.t. it may then look as follows:
public class MyView {
public MyView(ILevelLoader levelLoader){
this.levelLoader = levelLoader;
}
...
}
Often, this may not work, because the view is something instantiated by the framework directly rather than by the application. In such a situation you're forced to do it through an appropriate setter. It is some sort of MVC/MVP pattern.
Just for your interest, you might also want to take a look at IoC containers and dependency injection. Guice provided by Google is a nice framework I've already used on Android.
I hope I didn't miss the point, but here goes:
Generally you have either a function setting something (like the text for a textview), or an attribute you set in the xml.
Take a look over at this answer I got on a question: How to layout a 'grid' of images in the center of the screen
There are some things the custom view needs, but lets take an example: 'numColumns'.
you can set it using setNumColumns (that would be the equivalent of your loadLevels() ? )
you can ignore it, it'll revert to default.
you can set it as an attribute lik so: app:numColumns="3"
You can try to use the attribute or the default in the class to accomplish this.
Make your view an abstract class with an abstract method getLevels()? This way, when you instantiate the class if you forget to pass the levels in your code won't compile.
Whether or not this is better is a matter of taste I guess :)