Tracking when and which links are opened through my app - android

We have a social media kind of app where you can post content like messages, links, images etc. We would like to track when a link is pressed in the app, and which urls are opened through the app. The urls are detected in the textviews with the autolink "web" property. Is this possible to achieve with google/firebase analytics or similar?

although your question may not meet community standards.
I will try to answer, from my understanding ...
I believe that you are looking for URL tracking, this practice can be applied to applications and websites.
The most common method used today is:
Bit.ly
This tool, in addition to URL shortening. It can serve as an effective means of tracking and measuring.
but this tool also has its limitations. You have to study.
Google Analytics
With this tool you can create and use the Google Analytics tag.
So, follow this event.
It is understood that any url can be tracked with the created tag.
This practice becomes one of the most complex in metrics.
If you need to deepen your question further, be sure to comment.
Capture outbound links
Find out when users click a link to leave your site.
Note: This article applies only to sites tagged with the analytics.js snippet. (It does not apply to sites tagged with gtag.js.)
You can use Analytics Events to capture clicks on links that take users to a website other than your own.
Google Tag Manager
If you use Google Tag Manager to manage your Analytics installation, follow the instructions in Analytics Events to implement events.
Add the tag directly to your site
If you have added the Analytics tag directly to your site, you can copy and paste the script below into your own pages to set up Event measurement for outbound links. You should add this script in your page header, but not within the basic Analytics tag.
If you copy and paste this script exactly as it appears here, your outbound clicks will appear in your Analytics Events reports with a Category of "outbound" and an Action of "click". (In the snippet, these are shown in bold.) You can use these values, or change them and define your own values. Learn more about Event components.
This example assumes that you are using the analytics.js tag. See if you are using Classic Analytics (ga.js) or Universal Analytics (analytics.js).
<script>
/**
* Function that captures a click on an outbound link in Analytics.
* This function takes a valid URL string as an argument, and uses that URL string
* as the event label. Setting the transport method to 'beacon' lets the hit be sent
* using 'navigator.sendBeacon' in browser that support it.
*/
var captureOutboundLink = function(url) {
ga('send', 'event', 'outbound', 'click', url, {
'transport': 'beacon',
'hitCallback': function(){document.location = url;}
});
}
</script>
You'll also need to add (or modify) the onclick attribute to your links. Use this example as a model for your own links:
Check out example.com

Related

Firebase dynamic links campaign tracking not working

At work we are trying to use the optional campaign tracking UTM arguments when creating dynamic links through the firebase portal.
The dynamic links are working fine, and as far as I can tell from all the official documentation, just adding the UTM values in the final optional step when creating dynamic links should cause those values to be sent along with the dynamic_link_app_open event.
However, we are not seeing any attribution values when we look on the events OR conversions tabs for the dynamic_link_app_open event. We see that event is being sent but we just don't get the campaign attribution values so we have no idea what campaigns led to those events and conversions.
The documentation is really lacking on this particular feature and it's frustrating our marketing department which is ultimately ending up with the developers (i.e. me).
I have developed a work around, but it's a hack:
When creating the dynamic link on the firebase portal, I put utm_source, utm_medium and utm_campaign query strings directly into the deep link like so (not our actual deep link for security reasons, but you get the idea):
https://www.example.com?utm_source=Test&utm_medium=Test&utm_campaign=Test
Then in the client, I have added code to rip these out of the resulting deep link after passing the dynamic link through the firebase dynamic links SDK. With these 3 bits of information I can send an app_open event to firebase analytics via the FirebaseAnalytics SDK like so:
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, pendingDynamicLinkData -> {
if (pendingDynamicLinkData != null) {
Uri optionalDynamicDeepLink = pendingDynamicLinkData.getLink();
if (optionalDynamicDeepLink != null) {
List<String> utmSource = optionalDynamicDeepLink.getQueryParameters(UTM_SOURCE);
List<String> utmCampaign = optionalDynamicDeepLink.getQueryParameters(UTM_CAMPAIGN);
List<String> utmMedium = optionalDynamicDeepLink.getQueryParameters(UTM_MEDIUM);
if (!utmSource.isEmpty() && !utmCampaign.isEmpty() && !utmMedium.isEmpty()) {
String utmSourceParam = String.valueOf(utmSource);
String utmCampaignParam = String.valueOf(utmCampaign);
String utmMediumParam = String.valueOf(utmMedium);
Bundle params = new Bundle();
params.putString(FirebaseAnalytics.Param.SOURCE, utmSourceParam);
params.putString(FirebaseAnalytics.Param.CAMPAIGN, utmCampaignParam);
params.putString(FirebaseAnalytics.Param.MEDIUM, utmMediumParam);
FirebaseAnalytics.getInstance(this).logEvent(FirebaseAnalytics.Event.CAMPAIGN_DETAILS, params);
FirebaseAnalytics.getInstance(this).logEvent(FirebaseAnalytics.Event.APP_OPEN, params);
}
String dynamicDeepLink = optionalDynamicDeepLink.toString();
if (!handleDeepLink(dynamicDeepLink)) {
Generic.openLinkInCustomTabs(getApplicationContext(), deepLinkOptional);
}
} else {
if (!handleDeepLink(deepLinkOptional)) {
handleIntent(intent);
}
}
} else {
if (!handleDeepLink(deepLinkOptional)) {
handleIntent(intent);
}
}
}).addOnFailureListener(this, e -> {
if (!handleDeepLink(deepLinkOptional)) {
Generic.openLinkInCustomTabs(getApplicationContext(), deepLinkOptional);
}
});
Whilst this works, it begs the question; what is the point of the optional campaign tracking section when creating dynamic links? Presumably putting the utm_source, utm_medium and utm_campaign there is supposed to allow firebase to auto-magically populate the dynamic_link_app_open event with said campaign tracking data, but it doesn't.
For instance, here is how I've setup that optional final step:
I have then followed the dynamic link into the app several times as well as asking testers to do the same. I have waited over 36 hours (as I'm aware these events can take some time to propagate to the cloud) and we're seeing dynamic_link_app_open events build up, indicating an event is logged for our dynamic links, but when we drill into that event there is no UTM information collected.
Is this feature of firebase broken?
I can see this from official firebase documentation (https://firebase.google.com/docs/dynamic-links/analytics):
Which indicates that collection of UTM data from dynamic link clickthroughs is not supported on firebase, but is supported on google analytics. This isn't confusing at all (/sarcasm).
So presumably some of our data (i.e. the bit to do with campaign tracking) is collected/hosted by google analytics?
To add further confusion, the official documentation for firebase dynamic links states:
"If you mark Dynamic Link events as conversions, you can see how your Dynamic Links are performing on the Attribution page."
And then shows an image of the firebase portal UI which doesn't even match to reality:
I've searched and searched for an attribution tab on the firebase console but there isn't one... these docs are enough to drive a developer insane.
I reached out to Google, as the Issue still does not seem to be solved. Here is the answer:
"Currently, Firebase Dynamic Links UTM event tracking for iOS platforms is not supported due to the fingerprint matching mechanism for iOS platform limitation. As an action, I’ve linked this support ticket to our existing feature request to let our engineering team know of the increasing interest to have this utm_ tracking mechanism implemented for the iOS platform for FDL. I can’t share definite details or timeline for the release, but we are taking your interest moving forward to have this feature improvements. You can check our release notes for any updates."
I don't understand what "the fingerprint matching mechanism" exactly means. But I understand that it will take years until this Issue gets fixed.
I can understand your frustration, we are in the same problem for months now. I also think it should not be the way it works that you need to manually pick up the UTM Parameters. And I did find an older screenshot (from 2019) that showed that Dynamic Links SHOULD do this on their own:
[
This first part still works, but the Source/Medium/Campaign never make it into the Acquisition/Attribution reports. They DID do that in the past:
(example in screenshot is another Dynamic Link than in the first screenshot, sorry)
In talks with Google, it sounded as if they were indeed aware of this as a bug, but offered no specifics on whether or when this would be fixed.
So I can only confirm that you are not alone with your problem...
2021 updated answer:
I guess the problem is fixed and now you can see the events of the dynamic link from the DebugView with all the params (as #Lukas Oldenburg said)
According to this answer:
UTM parameters that you choose in UI are parameters for mobile
tracking. If you want to pass UTM parameters to your "fallback"
website, you need to add them to the fallback address itself.

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.

DFL parameter in Firebase Dynamic Links Builder

I need to programmatically build a dynamic link using the Dynamic Link Builder API on Android (https://firebase.google.com/docs/dynamic-links/android/create). This is the only option applicable for my case since I need to track click data and shorten links.
This link can be opened on the desktop, but the problem is that the link will be eligible only for mobile apps - the website is unable to recognize this link (this behavior is intentional). I would like the desktop user is directed to the website's main page.
Here is the quote from Firebase doc:
When users open a Dynamic Link on a desktop web browser, they will load this URL (unless param dfl is specified). If you don't have a web equivalent to the linked content, the URL doesn't need to point to a valid web resource. In this situation, you should set up a redirect from this URL to, for example, your home page.
I see I need dfl parameter. (dfl is The link to open on desktop, overriding param link.) How can I specify dfl parameter using Dynamic Links Builder on Android?
I know that I can specify dfl by building dynamic link manually - https://firebase.google.com/docs/dynamic-links/create-manually
But this approach is not useful for me since it has such constraints:
If you don't need to track click data in the Firebase console and you don't care if the links are long...
Does anybody know the right solution or some trick to achieve this? Any thoughts/ideas would be appreciated!
Seems, that simple appending does work...
When the builder composes the Uri, I append it with &dfl=XXXXX
When I try to open this link on browser PC it directs me to URL in dfl parameter, but on the device, it opens Play Store or app (if it's installed).
The absence of such method confused me, but the solution is found.

Track how many people visited your site from a banner app

So I have a banner on a android application and I want to track how many people came to my site clicked that banner ?
What is the best way?
Tracking the source of your traffic from an app is no different from a webpage.
Onclick of your banner you might trigger a web URL like site.com/page.html.
You can add parameter to the URL by adding the source site.com/page.html?source=app
And then on your server side you can check for the query parameter to find from where this request was coming from.
you have Several choices
you can send a parametr with your website's url , for example :
http://www.yourdomain.com?sendFrom=app
you can use analytics libraries (such as fabric,facebook analytics, firebase ,...) and register events with these services when user clicks on your banner.
The app isn't mine, only the add-banner, so I can't do anything app side.
What about this: https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-url-builder

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

Categories

Resources