I am trying to track campaigns (e.g. email) with the Android SDK v4, but it does not work because we cannot see any data in our Google Analytics account.
We are trying to use the code below to send data to Google Analytics:
URL we want to track:
URL SCHEME : scheme://www.example.com/commandes?utm_source=Mail_Invitation_Vente_ET&utm_medium=email&utm_term=ALL&utm_content=ALL&utm_campaign=TEST_CAMPAIGN
OR
URLs WEB:
http://www.example.com/commandes?utm_source=Mail_Invitation_Vente_ET&utm_medium=email&utm_term=ALL&utm_content=ALL&utm_campaign=TEST_CAMPAIGN
http://examplepetstore.com/index.html?utm_source=email&utm_medium=email_marketing&utm_campaign=summer&utm_content=email_variation_1
(the documentation : https://developers.google.com/analytics/devguides/collection/android/v4/campaigns)
Tracking Code:
Tracker tracker = GoogleAnalytics.getInstance(this).newTracker("UA-XXXXX");
tracker.enableExceptionReporting(true);
tracker.enableAdvertisingIdCollection(true);
tracker.enableAutoActivityTracking(true);
tracker.setScreenName("SCREEN/ android");
tracker.send(new HitBuilders.ScreenViewBuilder().setCampaignParamsFromUrl(URL_TO_TRACK).build());
GoogleAnalytics.getInstance(context).dispatchLocalHits();
We also tried this:
HashMap<String, String> campaignMap = new HashMap<>(3);
campaignMap.put("utm_source", SOURCE_TO_TRACK);
campaignMap.put("utm_medium", MEDIUM_TO_TRACK);
campaignMap.put("utm_campaign", CAMPAIGN_TO_TRACK);
tracker.send(new HitBuilders.ScreenViewBuilder().setAll(campaignMap).build());
We want to track a click on a specific link through the SCHEME URL (protocol or HTTP URL).
Could you tell us if we did something wrong in my code?
SDK version: game services: 7.5.0 I use Google Analytics v4.
source
share