android - How to set up google analytics with custom campaign attribution (not urls) -


I am trying to install my Google Analytics with "Campaign Attribution" on my Android app. Actually I have several NFC tags that launch my app, and each has an extra NDEF message with "Campaign ID" and I want each tag to be responsible for a different campaign in my Analytics account. To be held. However, the strings are already being passed correctly from the tag, and this part is working. Now I need to send them as part of the tracker.

I have a separate micropay. Java (directly copied from Google's Dev Site):

  Public class MyApplication application {Personal Stable last string PROPERTY_ID = " UA-XXXXXXX-X "is expanded; Public emacs tracker name {APP_TRACKER, GLOBAL_TRACKER, ECOMMERCE_TRACKER, // I really do not need this} Hashmaps  

} This analytics is very direct from Google Developers site on sdk4

, then in my camera activity where I want to track custom campaign parameters, I have

  Increases the activity of public class camera activity activity PictureCellback {String Campaign ID = "tag_1"; // In reality this has been passed from the tag. But I was sorted here for simplicity. Protected on Create (Bundle Saved Instantstate) {Tracker T = ((com.snappiesticker.app) getActivity (). GetApplication ()). GetTracker (TrackerName.APP_TRACKER); T.send (new HitBuilders.ScreenViewBuilder (.) Set ("tag", campaignID) .build ()); }}  

There are problems with the app's name: com.snappiesticker.app and getActivty () also the name is the name of my app's package. Should it be anything else? Apart from this, it can not be found, where getActivity () is defined. However, this is basically copied directly from the Google Dev website.

How can I send this tracker properly?

I think you have found your application class in your app manifest ( MyApplication ) Is set as:

  & lt; Application android: name = ". MyApplication" ... & gt;  

In addition, I think both, MyApplication class and CameraActivity class live in the same package (your app package com.snappiesticker.app ). Otherwise the package level visibility method getTracker () . If it is not, you will need to change the visibility in public:

  get public synchronized tracker gettracker (tracker name tracker ID) { 

For example, an example of your application class from the activity within your app, you will call the getApplication () method of that activity, then you type the application object in the frequency of your MyApplication class , Then you reach the getTracker () method Can.

  Enhances the implementation of the public class camera activation activity PictureCellback {CREATE (Bundled saved instenstate) on the protected void {tracker T = (MyApplication) getApplication ()) getTracker (TrackerName.APP_TRACKER) . T.send (new HitBuilders.ScreenViewBuilder (.) Set ("tag", campaignID) .build ()); }}  

Note that you will only need one tracker XML file (like global_tracker.xml ) if you want to tracker with an XML file

  Tracker T = analytics.newtracker (R.xml.global_tracker);  

If you only instruct a tracker with a PROPERTY_ID string value, then no such XML file is needed.


Comments