Android GTM: Possible to start new Google Analytics session manually? - android

So I'm working on implementing the latest Google Tag Manager into my application for use with Google Analytics. It's in place and everything is working great, but I do have a question.
Is it possible to manually start a new session within GA while using GTM to fire all of the events? For example, when I user logs out I would like to begin a new session, can I force that to happen using GTM?
Thanks!
OSFTW

You can do this with the sessionControl config var.
In GTM, in your GA tag config, it's under
More Settings > Fields to Set
Click the Add Field button, then for Field Name put sessionStart and for Value put "end" to force end of the current session or "start" to force (re)start of session.
Notes:
If you are using a Web Container Type, this is only available for Universal Analytics Tag Type. The Classic Google Analytics Tag Type does not have an equivalent, though you can maybe do some magic with _setSessionCookieTimeout if you're feeling ambitious.
If the GTM container is created as Mobile Container Type, it will only show Google Analytics as a Tag Type option, but this is a misnomer. Under the hood, GTM uses the Measurement Protocol for Mobile containers, and sessionControl is available for that.

Related

Firebase Dynamic Links - Can't get Url in android after install app from play store

If I install the app when clicking the dynamic link. All of that information from dynamic should be still available when I open the app for the first time.How can I get that information? It is not working when I use this: getInitialLink() returns Promise<string|null>;
Since, you haven't mentioned - I'm assuming you are having problems with shorter urls, if that's the case try putting the longer url.
Or refer here on Simon's answer: When I use the long instead of short links, everything works perfectly fine.
On Android, you use the getInvitation() method to get data from the Dynamic Link:
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, false).setResultCallback
(/* ... */);
Then, in the callback, you can get the data passed in the Dynamic Links link parameter by calling the getDeepLink() method:
Firebase Documentation - Use Case
For future reference or detailed answer on Firebase Dynamic Links
Behave just like normal Links
In cases where the application doesn’t require installation (say, if it’s already installed) then clicking the Dynamic Link will automatically open the link to the desired screen.
Dynamic Links have a very simple process flow:
The user begins by clicking the Dynamic Link
If the the needs of the Dynamic Link target are satisfied (this is, the application being installed) then the user is navigated to the target location
Otherwise, if the application requires install in order to navigate
to the Dynamic Link target, the the user is taken to the point of
install for the application. Once the application has been installed,
the user is navigated to the target location of the Dynamic Link
And if that wasn’t all, we can integrate Dynamic Links with Firebase Analytics to track the interaction with any links that we generate for our applications. But if we only require simple tracking, then we can use the automatic built-in analytics from the Dynamic Links panel within the Firebase Console where we can also obtain attribution and referrer information for interacted links with no extra effort required from our side.
What makes it different from Google Analytics?
One of the first things that came to my mind when I read about Firebase Analytics was, “What about my Google Analytics setup?”. So if you already have Google Analytics in place, then why would you make the switch to Firebase Analytics? Well, here’s a couple of differences between the two:
Audiences
We can use Firebase Analytics to create Audiences — these are groups of users that we can then interact with using other Firebase service such as Firebase Notifications and / or Firebase Remote Config.
Integration with other Firebase Services
An awesome thing with Firebase Analytics is that we can integrate other Firebase services with analytics. For example, creating an Audience of users who have experienced a crash reported through Firebase Crash Reporting.
Lower Method Count
The Google Analytics dependency on Android has a total count of 18,607 methods and has a total of 4kb used for dependancies. On the other hand, Firebase Core (for Analytics) has a method count of 15,130 and only 1kb used for dependancies.
Automatic Tracking
When we add the firebase core dependency, it will automatically begin tracking a collection of user engagement events and device information for us — this is useful if you’re looking to only collect the minimal data for your app.
Unlimited Reporting
For up to 500 events, Firebase Analytics provides us with unlimited reporting straight out of the box for free!
No Singleton Initialisation
When setting up Google Analytics on Android we are required to initialize a Singleton instance. Firebase Analytics are simply available by fetching the instance directly from where we wish to track data. This isn’t much effort obviously but just makes the setup flow slightly easier.
Single Console
All of the data for every Firebase service is available for a single console. That makes it both easier and quicker for us to navigate from checking the analytic stats for our app to viewing the latest crash reports.
It looks like this is a react-native-firebase open bug for android
For fix the only thing that is required to be changed in module code:
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
return FirebaseAppInvite.getInvitation(pendingDynamicLinkData) != null;
}
to
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(pendingDynamicLinkData);
if (invite != null && invite.getInvitationId() != null && !invite.getInvitationId().isEmpty()) {
return true;
}
return false;
}
Bug reference : https://github.com/invertase/react-native-firebase/issues/1273
Please Check Your Manifest file
open AndroidManifest.file => In your activity tag there is intent-filter tag put below line in that tag.
<data android:scheme="https" android:host="your.dynamic.link" />
<data android:scheme="http" android:host="your.dynamic.link" />
If already done then check this link for the full blog on the dynamic link with react native.
Link: http://blog.logicwind.com/react-native-dynamic-links-using-firebase/
I hope this will help. sorry for the typos.

How to move from Google-Analytics to Firebase-Analytics?

Background
In the recent months, Google has published a new Analytics alternative, called "Firebase Analytics" .
The problem
As the app already does have Google-Analytics, I find some obstacles that I can't see how to best handle.
The questions
Previously, "newTracker" function needed a property-id. Now I don't see it. Does it mean it doesn't need one?
Previously, "enableAdvertisingIdCollection " was available to collect ads info too. I can't find it in new APIs. Is it automatically collected?
"setDryRun" was available to disable sending the data to the servers, and now I don't see it. Does it mean it's automatically this way for debug versions of the app? Do all functions write to the logs?
Previously, I could track a "screen" :
public void setScreenName(String name) {
mGoogleAnalyticsTracker.setScreenName(name);
mGoogleAnalyticsTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
Now I don't see it, but as I've read, I think it's automatic, so it sends data of the activity lifecycle anyway. Is it true?
Probably the most important thing: previously I could track using category, action, label and value:
public void trackEvent(final String category, final String action, final String label, final long value) {
mGoogleAnalyticsTracker.send(new HitBuilders.EventBuilder()
.setCategory(category).setAction(action)
.setLabel(label).setValue(value).build());
}
and now I see a completely different way to track events ("custom events"), using bundles. Example:
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id);
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
How does it work? How is it shown in the website of Firebase Analytics? I suppose I could have the first parameter of logEvent behave like the category parameter of the Google-Analytics, but what can/should I do for the rest? According to the docs, this should be ok:
public void trackEvent(final String category, final String action, final String label, final long value) {
Bundle bundle = new Bundle();
bundle.putString("action", action);
bundle.putString("label", label);
bundle.putLong("value", value);
mFirebaseAnalytics.logEvent(category, bundle);
}
Which events are actually automatically being tracked (I ask this because some are said that I shouldn't use, here) ? Do they include purchases? app-invites? ads? Where do I see them in the console website ?
About logs, it says that the new SDK does it by :
You can enable verbose logging with a series of adb commands:
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
What do those commands do? How can I disable it? I've noticed it even gets shown in release version of the app...
Is the new SDK supposed to replace Google-Analytics? Is it suggested to fully move to it? Will Google-Analytics have any updates?
Lots of questions bundled together so I'll try to briefly answer most of them:
Google Analytics reports on tracker-ids, Firebase Analytics reports on applications. There is only one id in the application defined in your google-services.json. The ID is translated to a string resource by google services plugin under "google_app_id" name. All events from the app are reported to this single id.
Firebase Analytics reports AdId automatically. You don't need to enable it.
There is no dryRun feature. You can either use separate google-services.json during development, filter out development version using the app version or add user-property to mark the app instances used for development.
You can report screens with
Bundle params = new Bundle();
params.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "screen");
params.putString(FirebaseAnalytics.Param.ITEM_NAME, "screen name");
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);
You can log custom event with the same params
Bundle params = new Bundle();
params.putString("category", category);
params.putString("action", action);
params.putString("label", label);
params.putLong("value", value);
firebaseAnalytics.logEvent("xyz_event", params);
The "ga_" prefix is reserved and your analytics will fail if you use it. Instead, use "xyz_" where xyz is your company's initials, for example.
Do not use the category as event name unless you have very few categories you want to track. Firebase Analytics supports up to 500 event names. Logging more than that will cause some of your data to be ignored.
There is a list of reserved event names in the beginning of the FirebaseAnalytics.Event class. It roughly represents the automatic events reported.
Firebase Analytics has debug logging disabled by default. It only logs errors and warnings. If you don't enable debug logging and your app is correctly configured there are only 2 lines that are being logged when the app starts with instructions on how to enable debug logging. There is nothing to disable in production and there is no equivalent to setLogLevel(ERROR) from Google Analytics. WARN is the default logging level. You can only enable logging on individual device by running the adb command on the device). That helps you avoid shipping app in production with debug logging enabled.
Google Analytics SDK for Android and iOS is not deprecated and will be supported and updated for foreseeable future. You don't need to move away from it if you already invested using it in your app and it is meeting your needs.
Google Analytics is a freemium web analytics service offered by Google that tracks and reports website traffic.1 Google launched the service in November 2005 after acquiring Urchin.
Firebase is a cloud services provider and backend as a service company based in San Francisco, California. The company makes a number of products for software developers building mobile or web applications.
How to move from google analytics to firebase analytics?
Google Analytics (GA) and Firebase Analytics (FA), despite their common name, are widely different in many aspects.
While GA is a general-purpose (and more web oriented) analytics tool, Firebase was built keeping mobile in mind: therefore, the feature set is different between the two, with some things that were added in FA and things that are missing from GA.
More specifically, these are some noteworthy points when considering Firebase Analytics:
Real-time view is missing
Events are available after a 4-6 hours period
Behavior Flow (from GA) is missing
The Audiences feature a big advantage of FA and, coupled with Notifications, allows you to engage with a specific group of users
When using Firebase Crash Reporting, an audience with users who experienced a crash is automatically created
Funnel analysis makes much more sense than in GA, since FA is based on events and not on screen views
Free and unlimited, except for the number of types of events (limited to 500); no limits on the volume of events per each type
Some events are logged automatically (i.e., sessions based on Activity lifecycle)
Relatively low methods footprint, compared to GA's methods count
Dead-easy to setup, there is no singleton to initialize, just include the Gradle dependency and start logging events
All-in-one console, if you plan on using other Firebase services
As to if one should consider switching from one to the other, or if to keep both in parallel, the answer is: it depends.
If you were using GA extensively before, chances are that you would be missing some of its feature when switching completely to FA.
However, if this is a fresh start for your project, FA is much more prone to a cross-platform mobile-oriented environment, so you may very well consider it as your own analytics tool.
On a side note, keep in mind that Firebase has just launched and Google has plans on adding more features in the coming weeks (e.g., real-time dashboard).
For tutorial you can find here https://firebase.google.com/docs/analytics/android/start/

Google Tag Manager for Xamarin Android app

As of my googled data, i got to know how to integrate GTM with the xamarin app. Based the url here.
The Tag manager is able to push the events to the GTM.
So question is, how to get the application data associated with GTM in the Google Analytics.
I get some links and videos while surfing for this, all are explaining about the GA for Web applications. Am looking the same for Xamarin Android application.
Edit:
Adding to the question, Will GTM capture all the button clicks with out pushing the data?
Will the data like 'submit button clicked' is transferred to GA via GTM?
Thanks
Suppose you have an image and want to know how many people clicked on it.
When the user clicks on the image you run this piece of code:
var dataLayer = new Dictionary <string, object> ();
dataLayer.Add ("event", "imageClick");
dataLayer.Add ("imageName", "Bart Simpson");
Android.Gms.Tagmanager.TagManagerClass.GetInstance (context).DataLayer.Push (dataLayer);
To get this data on GA through GTM you have to follow these steps on your GTM Container:
Create a new TAG
Choose Google Analytics as the product
Set the GA's Tracking ID and Track Type to Event
Set the Category to {{Platform}} (this will get Android)
Set the Action to {{Event}} (this will get imageClick)
Set the Label to a new Variable of the DataLayer type and named as imageName (this will get Bart Simpson)
Set Fire On to Any Event (this will trigger everytime an event is pushed to GTM)
Save and publish your container
Now you can see the events popping in you GA Console. You can send multiple variables in one push, but you will have to create multiple Tags with different events to see them in GA.
Edit:
No, you must push events to the DataLayer.
Only if you configure the TAG as explained above.
On GTM there is basic tracking for web that is the same as inserting the google analytics tracking code on each page of your website, but that only works for basic stuff like page views, not custom events on buttons.
Source

Implementing Adword Remarketing with GTM Android

I am implementing GTM in Android project which will not use GoogleAnalytics SDK or Adword SDK,but I want data in Google Analytics and Adword.
In order to achieve this,
I have implemented Google Anaytics tag in GTM,Added Rule {Always},
Screen Name data is being sent to GTM which is reflected in Analytics,This is tested and working properly
I need InstallReferrals for Application which also should manage through GTM.
To achieve this,
Added a tag in GTM for Adword with the type Adword Remarketing,
Added ConversionId and label from Adword.
Added tagmanager.InstallReferralService and tagmanager.InstallReferralReceiver to Android manifest.xml.
According to source code of InstallReferralService it passes data to CampaignTrackingService of Analytics,which should upload data to Adword and Google Analytics.
But I am unable to get any data.
Please correct me if I am doing anything wrong in this process.
I also need Adword Conversion Tracking to be used through GTM without Adword SDK.
Not sure how to achieve this.

How to configure Android Google Tag Manager v4 with Google Analytics (Universal Analytics)

I'm trying to use Google Tag Manager to report screenviews and events to Google Analytics. I followed the google's tutorial but I'm not able to even report the screenviews.
Also spent hours searching in google but there was no match. Almost all the information available is for Android's v3 or the old GTM web interface.
This is my configuration
Pushing the event to the data layer throws no error. However screenName seems not been sent.
Java code
public static void pushScreenViewEvent(#NonNull Context context, #NonNull String screenName) {
DataLayer dataLayer = TagManager.getInstance(context).getDataLayer();
dataLayer.pushEvent("screenView",
DataLayer.mapOf("screenName", screenName));
}
Debug log after push data
02-23 19:12:39.376 31787-31888/com.example.debug V/GoogleTagManager﹕ Sending hit to service PATH: https: PARAMS: sr=1080x1776, a=558676027, v=1, ht=1424686354314, an=Example app, ul=ja-jp, t=appview, _u=.L, tid=UA-XXXXXX-1, cid=XXXXXX, aid=com.example.debug, av=1.0.0,
Google Play Services version
compile 'com.google.android.gms:play-services-base:6.5.87'
There's this tutorial but it is for the old GTM v3 with the old GTM web screenshots
https://developers.google.com/tag-manager/android/v3/ua#screenviews
Ok, it was my fault.
There was two problems.
Fields to set were wrong
In order to track the screen in GA it's necessary to set the Screen Name's Measurement protocol parameter &cd
In my case Client Id and User Id are also necessary, that's why I send &ci and &uid
I was using a default binary container from a different test account. After use the correct container it worked like a charm.
It seems like firing rule is incorrect.
Try something like {{event}} equals screenView or Always as firing rule.
And it will take 24hrs to update in the Google Analytics dashboard, so it will not appear in the real time. Let me know if it doesn't work.

Categories

Resources