
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
com.github.mbiamont:ga-annotations-library
Advanced tools
Gradle plugin to use Google Analytics Annotations Library
#Google Analytics Annotations
Android library to use Google Analytics through annotations.
In your build.gradle
file add these lines :
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.mbiamont:ga-annotations-plugin:1.1.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'GAAnnotations'
(...)
dependencies {
(...)
compile 'com.github.mbiamont:ga-annotations-library:1.2.1'
}
In the onCreate()
method of your Application
class, add this line :
AnalyticsManager.getInstance().init(context, "YOUR_GOOGLE_ANALYTICS_TRACKER_ID");
@TrackEvent(category = "ui_action", action = "on_click", label = "on_click_login_button", value = 1)
private void onLoginButtonClicked(){
(...)
}
@TrackScreen(name = "MainActivity")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
(...)
}
If you have to use multiple trackerId in your application, you can define for each event or screen the tracker to use.
Example :
@TrackScreen(trackerId= "UA-XXXX1", name = "MainActivity")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
(...)
}
If you just want to check if the tracks are correctly implemented; you can use the debugMode. It'll print tracks in LogCat instead of send them.
Just replace AnalyticsManager.getInstance().init()
by
AnalyticsManager.getInstance().debugMode(context, true);
Sometimes, you cannot use annotations (if your tracks require a condition for example). In this case, you can use trackers manually :
private void onLoginButtonClicked(){
if(user.isLogged()){
AnalyticsManager.getInstance().trackEvent(new Event.Builder()
.withCategory("ui_action")
.withAction("on_click")
.withLabel("on_click_login_button")
.build());
//or simply : AnalyticsManager.getInstance().trackEvent("ui_action", "on_click", "on_click_login_button", 1);
}
(...)
}
or
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(user.isLogged()){
AnalyticsManager.getInstance().trackScreen("MainActivity");
}
(...)
}
Copyright 2015-2016 Melvin Biamont
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
FAQs
Gradle plugin to use Google Analytics Annotations Library
We found that com.github.mbiamont:ga-annotations-library demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.