I am adding Google Analytics in my app. When I go to Real Time > Overview
I see 1.0
under App Version
. My question is where is Google Analytics getting this 1.0
number from?
This is how I am starting Analytics in the onCreate()
of my Launcher Activity
:
analytics = GoogleAnalytics.getInstance(MainDrawerActivity.this);
analytics.setLocalDispatchPeriod(1800);
tracker = analytics.newTracker("UA-XXXXXX-X"); // Replace with actual tracker/property Id
tracker.enableExceptionReporting(true);
tracker.enableAdvertisingIdCollection(true);
tracker.enableAutoActivityTracking(true);
My project has multiple gradle files. I am pasting them all here:
Here is my gradle file and also my Android Manifest: build.gradle: (for my Project: xxx...)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle: (for my Module: app)
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "xxx.xxx.xxx"
minSdkVersion 16
targetSdkVersion 22
versionCode 58
versionName "2.0.13"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
encoding "UTF-8"
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
}
build.gradle for Module: circularImageView (this is a library project) apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 60
versionName "2.0.14"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Beginning of my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xxx.xxxx.xxxxxxxx"
android:installLocation="internalOnly"
android:versionCode="58"
android:versionName="2.0.13" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
Another point to note is that -- before the "1.0" version seen, I was in Eclipse but this is the first time I am on Android Studio but I used the Gradle Method to add Google Analytics to my account.
You can use global tracker which provided by Google Analytics v4. Before you starting to add global tracker within your apps, let's have this structure first:
app_tracker.xml
ecommerce_tracker.xml
global_tracker.xml
Then, create a new Java Class named
App
and extend it withApplication
:Alter your manifest slighlty:
And finally, hit the tracker within
MainActivity
class:Voila! Google Analytics are activated! For more information, see:
Advanced Configuration - Android SDK v4
Google Analytics SDK v4 for Android - Getting Started
TAG: