Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trackView() doesn't track #274

Closed
ventr1x opened this issue Aug 8, 2016 · 26 comments
Closed

trackView() doesn't track #274

ventr1x opened this issue Aug 8, 2016 · 26 comments
Milestone

Comments

@ventr1x
Copy link

ventr1x commented Aug 8, 2016

Plugin is not tracking views.
Events are working fine.
web-app (ofc not using the plugin) is working fine.

google reports http status -1 (not always), which seems not to track.
Also if sometimes it's tracking at least the intial load, it never reports the correct active page or page title, it always takes it out of the title-tag (basically sends a hit without paramters).

I've also got a warning which i cant really place (also only sometimes):
Aug 8 10:57:12 iPhone *[2171] <Warning>: INFO: GoogleAnalytics 3.14 -[GAIAnalyticsPropertiesStore propertyRecordForTrackingId:] (GAIAnalyticsPropertiesStore.m:464): Record for tracking id UA-* not found

Current log was using the sample line with "Screen Title".
I tried multiple different variations.

My implementation is pretty basic atm as I had to ditch ngCordova for it (they're still using windows.analytics)

var d = $q.defer();
$window.ga.startTrackerWithId(GA_ID, function (response) {
    d.resolve(response);
}, function (error) {
    console.log("startTrackerWithId err -> " + error);
    d.reject(error);
});

$window.ga.trackView('Screen Title');

var d = $q.defer();
$window.ga.trackEvent(category, action, label, value, function (response) {
    d.resolve(response);
}, function (error) {
     console.log("trackEvent err -> " + error);
    d.reject(error);
});
Aug  8 11:28:18 iPhone *[2203] <Warning>: Apache Cordova native platform version 4.2.0 is starting.
Aug  8 11:28:18 iPhone *[2203] <Warning>: Multi-tasking -> Device: YES, App: YES
Aug  8 11:28:18 iPhone *[2203] <Warning>: Using UIWebView
Aug  8 11:28:18 iPhone *[2203] <Warning>: [CDVTimer][handleopenurl] 0.142992ms
Aug  8 11:28:18 iPhone *[2203] <Warning>: Unlimited access to network resources
Aug  8 11:28:18 iPhone *[2203] <Warning>: Unlimited access to network resources
Aug  8 11:28:18 iPhone *[2203] <Warning>: [CDVTimer][intentandnavigationfilter] 3.185034ms
Aug  8 11:28:18 iPhone *[2203] <Warning>: [CDVTimer][gesturehandler] 0.189006ms
Aug  8 11:28:18 iPhone *[2203] <Warning>: [CDVTimer][statusbar] 53.615034ms
Aug  8 11:28:18 iPhone *[2203] <Warning>: [CDVTimer][keyboard] 1.789987ms
Aug  8 11:28:18 iPhone *[2203] <Warning>: [CDVTimer][socialsharing] 73.350012ms
Aug  8 11:28:18 iPhone *[2203] <Warning>: Currently running release version 2016.08.08-11.26.10
Aug  8 11:28:18 iPhone *[2203] <Warning>: [CDVTimer][TotalPluginStartup] 158.453047ms
Aug  8 11:28:26 iPhone *[2203] <Warning>: startTracker ; UA-*
Aug  8 11:28:26 iPhone *[2203] <Warning>: THREAD WARNING: ['UniversalAnalytics'] took '10.887939' ms. Plugin should use a background thread.
Aug  8 11:28:26 iPhone *[2203] <Warning>: INFO: GoogleAnalytics 3.14 -[GAIReachabilityChecker reachabilityFlagsChanged:] (GAIReachabilityChecker.m:159): Reachability flags update: 0X000002
Aug  8 11:28:26 iPhone *[2203] <Warning>: Error during update: The operation couldn’t be completed. (HCPPluginError error -1.)
Aug  8 11:28:36 iPhone *[2203] <Warning>: INFO: GoogleAnalytics 3.14 -[GAIBatchingDispatcher hitsForDispatch] (GAIBatchingDispatcher.m:368): No pending hits.
Aug  8 11:30:14 iPhone *[2203] <Warning>: trackView
Aug  8 11:53:03 iPhone *[2228] <Warning>: VERBOSE: GoogleAnalytics 3.14 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:517): Saved hit: {
        parameters =     {
            "&_crc" = 0;
            "&_s" = 3;
            "&_u" = ".oKoDK9BL";
            "&_v" = "mi3.1.4";
            "&a" = 1708808294;
            "&aclid" = "<null>";
            "&aid" = "de.*";
            "&an" = *;
            "&anid" = "<null>";
            "&ate" = "<null>";
            "&av" = "1.0.1";
            "&cc" = "<null>";
            "&cd" = "Screen Title";
            "&ci" = "<null>";
            "&cid" = "edd1f599-e117-4edb-b17a-a6b679ad325c";
            "&ck" = "<null>";
            "&cm" = "<null>";
            "&cn" = "<null>";
            "&cs" = "<null>";
            "&dclid" = "<null>";
            "&dm" = "iPhone6,2";
            "&ds" = app;
            "&gclid" = "<null>";
            "&gmob_t" = "<null>";
            "&idfa" = "<null>";
            "&sr" = 640x1136;
            "&t" = screenview;
            "&tid" = "UA-*";
            "&uid" = 51;
            "&ul" = "en-de";
            "&v" = 1;
            "&z" = 13653181779649986564;
            gaiVersion = "3.14";
        };
        timestamp = "2016-08-08 09:53:03 +0000";
    }
Aug  8 11:53:12 iPhone [2228] <Warning>: VERBOSE: GoogleAnalytics 3.14 -[GAIRequestBuilder requestPostUrl:payload:compression:] (GAIRequestBuilder.m:167): building URLRequest for https://ssl.google-analytics.com/batch
Aug  8 11:53:12 iPhone *[2228] <Warning>: VERBOSE: GoogleAnalytics 3.14 -[GAIBatchingDispatcher dispatchWithCompletionHandler:] (GAIBatchingDispatcher.m:632): Sending hit(s) POST: https://ssl.google-analytics.com/batch
Aug  8 11:53:12 iPhone *[2228] <Warning>: INFO: GoogleAnalytics 3.14 -[GAIBatchingDispatcher didSendHits:response:data:error:] (GAIBatchingDispatcher.m:226): Hit(s) dispatched: HTTP status 200
Aug  8 11:53:12 iPhone *[2228] <Warning>: INFO: GoogleAnalytics 3.14 -[GAIBatchingDispatcher deleteHits:] (GAIBatchingDispatcher.m:529): hit(s) Successfully deleted
Aug  8 11:53:12 iPhone *[2228] <Warning>: INFO: GoogleAnalytics 3.14 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:237): 3 hit(s) sent
@victorsosa
Copy link
Collaborator

victorsosa commented Aug 8, 2016

HI,

they're still using windows.analytics,

is still been supported

Which version of google-analytics-plugin are you using??

@ventr1x
Copy link
Author

ventr1x commented Aug 8, 2016

The newest, installing it without version paramter.
And with window.analytics/ngCordova I get an instant crash on first pageview.
But there is no harm in implementing it manually. I have a service for the web version anyways.

cordova-plugin-google-analytics npm * 1.5.3 n/a android,ios,winphone

@victorsosa
Copy link
Collaborator

victorsosa commented Aug 8, 2016

And with window.analytics/ngCordova I get an instant crash on first pageview

can you post that error log too, please?

@victorsosa victorsosa added this to the 1.5.0 milestone Aug 8, 2016
@victorsosa victorsosa added the bug label Aug 8, 2016
victorsosa added a commit to peoplewareDo/google-analytics-plugin that referenced this issue Aug 8, 2016
@victorsosa
Copy link
Collaborator

The only issue I fixed for now is this:

Aug  8 11:28:26 iPhone *[2203] <Warning>: startTracker ; UA-*
Aug  8 11:28:26 iPhone *[2203] <Warning>: THREAD WARNING: ['UniversalAnalytics'] took '10.887939' ms. Plugin should use a background thread.

Now the startTrackerWithId() is using runInBackground

victorsosa added a commit that referenced this issue Aug 8, 2016
fix issue #274 startTrackerWithId() is using runInBackground
@victorsosa
Copy link
Collaborator

Please try with the v1.5.5 and let me know.

@victorsosa
Copy link
Collaborator

victorsosa commented Aug 8, 2016

This seems to be related to issue #168, please check that too

@ventr1x
Copy link
Author

ventr1x commented Aug 8, 2016

It also doesn't work on android, so it's probably not an issue with the plist file (I'm also currently using build.phonegap).

I'll give ngCordova another try (I used .26), but 1.5.5 gives me a build error:

/project//Plugins/cordova-plugin-google-analytics/UniversalAnalyticsPlugin.m:179:22: error: variable is not assignable (missing __block type specifier) pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; ~~~~~~~~~~~~ ^ 2 warnings and 1 error generated.

@victorsosa
Copy link
Collaborator

victorsosa commented Aug 8, 2016

Sorry, I don't have an IOS to compile this, I am committing the fix. I will need you help.

@victorsosa
Copy link
Collaborator

cordova-plugin-google-analytics@1.5.6
ready

@ventr1x
Copy link
Author

ventr1x commented Aug 8, 2016

Sadly ngCordova does crash on ios for me on first call of trackView (tested with 1.5.3 and newest ngCordova)
$cordovaGoogleAnalytics.trackView("Home Screen");

Aug 8 14:46:01 iPhone[2279] <Error>: -[NSNull rangeOfString:]: unrecognized selector sent to instance 0x1a0037490 Aug 8 14:46:01 iPhone[2279] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull rangeOfString:]: unrecognized selector sent to instance 0x1a0037490' *** First throw call stack: (0x18209adb0 0x1816fff80 0x1820a1c4c 0x18209ebec 0x181f9cc5c 0x10008d7b0 0x100091804 0x100050108 0x181ae54bc 0x181ae547c 0x181af3914 0x181af30b0 0x181cfd470 0x181cfd020)

On Android I get an "invalid action". I cannot even guess what i'd be doing wrong by simply calling trackView.

@victorsosa
Copy link
Collaborator

ok, test the v1.0.0 which doesn't have the new Campaign Measurement, this is been cause by the last code changes.

@ventr1x
Copy link
Author

ventr1x commented Aug 8, 2016

Besides the ngCordova issue it comes down to trackView not getting the hit through.
Google responds with "Hit(s) dispatched: HTTP status -1"
Which is, as far as I could (not) find, nowhere at all documented.

I also need the campaign measurement, so I can't use ngCordova anyways.

What I personally need (and use on the web/mobile site):
$window.ga('set', 'page', viewName);
$window.ga('send', 'pageview');

With viewName something like /controller/action/id.. a path basically.
Does $cordovaGoogleAnalytics.trackView(viewName); provide this (analytics is not even showing the correct title)?
I had no luck with either ngCordova + v1.0.0 or my own service and v1.5.x
$window.ga.trackView($ionicHistory.currentTitle(), viewName);
Sometimes it tracks the initial page load, but that's about it (never with the right title or campaign measurement).

What i'm also wondering: When I pass a campaign measurement, why does it not appear in the parameters of the debug message?

There are no errors besides the http status and invalid action on android (i guess -1 just says 'unknown error'). Event tracking works with any version.

@lavarith
Copy link

lavarith commented Aug 9, 2016

I also couldn't get pageviews to track on Android using v1.5.6 Events track fine, though. Switching to v1.0.0 didn't solve this problem.

@lavarith
Copy link

lavarith commented Aug 9, 2016

Using phonegap build, I have:

<plugin name="cordova-plugin-google-analytics" source="npm" spec="1.0.0" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-navigation href="http://*.google-analytics.com" />
<allow-navigation href="https://*.google-analytics.com" />

in my config.xml

in my onDeviceReady, I have:

// Initialize Google Analytics
window.ga.startTrackerWithId('UA-XXXXXXXX-1');
window.ga.trackEvent('Launch', 'Start'); // Store The Event

// Initialize Notifications
initializeNotifications();

// Check login
var uuid = localStorage.getItem("uuid");
$("#uuid").html(uuid);

if($.mobile.activePage.is('#loading')){
    if(uuid){
        window.ga.setUserId(uuid); // track users via GA
        window.ga.trackEvent('Launch', 'Login', 'Auto');
        saveNotificationID(uuid);
        var page = CheckUser();
        $.mobile.changePage($("#" + page), {transition: "none"});
    }else{
        window.ga.trackView('SignInPageView');
        $.mobile.changePage($("#signin"), {transition: "none"});
    }
    StopLoading();
}

It loads the #signin page and I see the user pop up in real-time on GA. No page view though.

@victorsosa
Copy link
Collaborator

victorsosa commented Aug 9, 2016

@lavarith I am getting pageviews to track on Android using v1.5.6.

Please use window.ga.trackView('Login');

@lavarith
Copy link

lavarith commented Aug 9, 2016

@victorsosa

No such luck. Switched back to 1.5.6 and changed to:

// Initialize Google Analytics
window.ga.startTrackerWithId('UA-XXXXXXXX-1');
window.ga.trackEvent('Launch', 'Start'); // Store The Event
window.ga.trackView('Login');

I get the event, but no page view:
screen shot 2016-08-09 at 9 12 31 am
screen shot 2016-08-09 at 9 12 46 am

@lavarith
Copy link

lavarith commented Aug 9, 2016

I assume that I've got the 'Screen Name' wrong. I'm using a single page architecture with:

<body>
    <!-- Loading Page -->
    <div data-role='page' id="loading">
        ...
    </div>
   <div data-role='page' id="signin">
       ...
   </div>
<body>

How do I determine the page name? or is that value anything you want?

@victorsosa
Copy link
Collaborator

victorsosa commented Aug 9, 2016

@lavarith You looked into the GA report for Screen section?
The screen name is just a string value, it doesn't have to be correct neither the right one.

@lavarith
Copy link

lavarith commented Aug 9, 2016

I'm not sure where that is. I'm using a Web API key. Should I be using an app one?

@victorsosa
Copy link
Collaborator

OHH, I think you have the wrong config; you are using a web app GA instead of the movil app GA.

Mobile app use the concept of screen instead of page view. You need somehow to change the type or create a new tracking.

screenshot from 2016-08-09 10-36-12

@ventr1x
Copy link
Author

ventr1x commented Aug 9, 2016

That was my problem and I feel ashamed :)
That happens when you do contract work and have to rush things you're not properly prepared for (never used ga for mobile).
Funnily my client is a marketing company that also doesn't know how to properly configure ga.

There are still minor issues, like some devices getting tracked as "Desktop" (in mobile view...), but that doesn't matter much and is google's error.

So maybe google is throwing a http status -1 if the api doesn't find a mobile view/property attached to the id? Proper documentation/error for this case would've saved me an entire day :(

You can also just create a new data view instead of a new property.

@ventr1x ventr1x closed this as completed Aug 9, 2016
@lavarith
Copy link

lavarith commented Aug 9, 2016

That worked! Thanks.

@ventr1x In fairness, I found several blog posts saying that using the web version was what you're supposed to do. The README does say to use the "Google Analytics Mobile App property", but it may be worth clarifying this further in the directions.

@victorsosa
Copy link
Collaborator

Both: You welcome, XD

@Lyncros
Copy link

Lyncros commented Nov 15, 2016

Hello All, we're usiung the plugin, have everything configured and we're using an mobile app property in our ionic/cordova app. The app is reporting in real time and tracking events, but we can't get it to track reccords in the remaketing audience we creates. Anyone could help us figure out what to do or where to look next?

@victorsosa
Copy link
Collaborator

@Lyncros I think the remaketing audience (IDFA) need a lot of data before the report works properly.

zalog added a commit to zalog/ro-diaspora that referenced this issue Dec 14, 2016
Adaugă `cordova-plugin-google-analytics@1.6.0` deoarece la momentul ăsta, ultima versiune, respectiv 1.7.4 are niște buguri de trackView.
danwilson/google-analytics-plugin#274
@pugwonk
Copy link

pugwonk commented Jan 18, 2018

Google seem to have changed it so that app and web views can be amalgamated. They say here:

If you send web and app data for the same property (UA-XXXXX-Y), Google Analytics will display both sets of data in views for that property. This allows for combined app and web views.

I'm using this plugin to send TrackViews to a web property but they're not appearing. :(

EDIT: In order to see these, you have to create a new "View" in Google Analytics for app data. At that point the live stream will show page views fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants