Thursday, March 17, 2016

Google Tag Manager and Analytics Integration

Firstly, we can say that you can send events from your app to GA directly. However, you can send events to GTM and then GTM will send those to analytics. Many reasons can be said why to use GTM over GA such as in here. But it always a Design/Need decision!

Anyhow, For Android, A draft implementation is at https://developers.google.com/tag-manager/android/v4/#getting-started

Check it, you may have some questions, you would find the answers in here I hope. So those are some of the lessons I learnt:
- Event Names and keys at Android code should match the corresponding ones at GTM.
dataLayer.pushEvent("openScreen",      DataLayer.mapOf("screenName", screenName));
- If you send Events from GTM to GA, the "value" field should be always Integer . if not, it will not be sent
public static void pushEvent(Context context, String event,String category, String label, Integer labelValue) {
        DataLayer dataLayer = TagManager.getInstance(context).getDataLayer();
        dataLayer.pushEvent(event, DataLayer.mapOf("eventCategory", category,"eventLabel", label, "eventValue", labelValue);
    }

- Configure GTM with Variables, Triggers, and Tags. as described here: https://developers.google.com/tag-manager/android/v4/ua#create-transaction-tag

- Use pushEvent rather than push. It is easier!

Thursday, March 10, 2016

Wednesday, March 9, 2016

Android font and caligraphy



So if you want to set an external font to a text view, you have different options:

- A common step: Get the font and put it under assets/fonts folder (create it if it not already created)

1 - Use this Gist:
Typeface typeface = Typeface.createFromAsset(getAssets(),"Roboto-Regular.ttf");
TextView textview = (TextView) findViewById(R.id.textview);
textview.setTypeface(typeface); 
2 - Use DataBinding Lib as described in here: fontbinding
3- Use XML attributes through custom widget: this is a good blog covering it all Custom fonts