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

Track a Cordova / Ionic app with Matomo #14375

Open
mattab opened this issue Apr 25, 2019 · 11 comments
Open

Track a Cordova / Ionic app with Matomo #14375

mattab opened this issue Apr 25, 2019 · 11 comments

Comments

@mattab
Copy link
Member

@mattab mattab commented Apr 25, 2019

The goal of this issue is to collect feedback around how people track Cordova/ionic mobile apps using Matomo.

One of the limitations is that cookies may not be supported in these apps, so if this is confirmed, tracking accuracy may be affected as explained in this faq (impact of tracking without cookies)

Maybe the solution to this issue could involve writing a Cordova / ionic plugin for Matomo tracking, like it exists for others (GA, Mixpanel, etc.). Or maybe we could make our own JavaScript tracker work by using Local storage when cookies are not available.

Would also be good to create a new FAQ about Cordova / ionic analytics with Matomo to let people know when they search (we had a similar one about phonegap tracking).

Be great if you can comment in this issue with your feedback measuring a Cordova / ionic app with Matomo 👍

@GitFr33
Copy link

@GitFr33 GitFr33 commented Apr 26, 2019

I have had very good results using Matomo for analytics in Cordova Apps.

The integration has been quite straight-forward and I've had no issues with lack of cookies. I did have to set up my own do-not-track option using localstorage.

One area of Cordova app analytics that is a challenge with Matomo is new user attribution. I have not managed to track where new app installs come from using matomo.

@mattab
Copy link
Member Author

@mattab mattab commented May 17, 2019

Thanks for the feedback @GitFr33 👍

@mattab
Copy link
Member Author

@mattab mattab commented May 17, 2019

@APalau82
Copy link

@APalau82 APalau82 commented Jun 24, 2019

Hey

Did anyone succeed in implementing Matomo into Ionic app ?

I tried to follow the instructions with the 'ngx-matomo' package but the tracker did not separate the pages. I had every time the same page tracked, with the title of my 'index.html' page title...

Please any help or example of Matomo integration with Ionic would be really appreciated

@GitFr33
Copy link

@GitFr33 GitFr33 commented Jun 24, 2019

I don't know about ionic and whether it has a build in method for handling pseudo page load type navigation but using Matomo with cordova apps that are a single (index.html) file with asynchronous javascript navigation I used the trackPageView() with a custom page title to set retentive page view data.

@APalau82
Copy link

@APalau82 APalau82 commented Jun 26, 2019

I don't know about ionic and whether it has a build in method for handling pseudo page load type navigation but using Matomo with cordova apps that are a single (index.html) file with asynchronous javascript navigation I used the trackPageView() with a custom page title to set retentive page view data.

Thanks. In the same idea I used the matomo tracker component with the ngx-matomo package.

// component
import { Component } from '@angular/core';
import { MatomoTracker } from 'ngx-matomo';
 
@Component({
  selector: 'app',
  template: `<router-outlet></router-outlet>`
})
export class AppComponent {
  constructor(
    private matomoTracker: MatomoTracker
  ) { }
 
  ngOnInit() {
    this.matomoTracker.setUserId('UserId');
    this.matomoTracker.setDocumentTitle('ngx-Matomo Test');
  }
}

But never get the tracker on my dashboard. I never saw the ngx-Matomo Test page title in my stats.

@GitFr33
Copy link

@GitFr33 GitFr33 commented Jun 28, 2019

I'm not sure but I believe that setDocumentTitle() has to be called before trackPageView(), have you confirmed that you are calling them in the correct sequence?
Also, you could try specifying the page title as the argument of trackPageView([customTitle]) i nstead of using setDocumentTitle which is how I got it working.

@jorisdrenth
Copy link
Contributor

@jorisdrenth jorisdrenth commented Jul 14, 2019

Just set up Matomo in my Ionic app, and it works pretty good.

I followed the instructions of the readme of ngx-matomo. At every page of my app I added the following to ngOnInit():
ngOnInit() { this.matomoTracker.trackPageView('PageTitle'); }
Update: set this in ionViewDidLoad() for better accuracy.

Pageviews show up in my Matomo dashboard, although the url is the same for all pageviews (http://localhost/). The report at Behaviour > Page titles gives an overview of all viewed pages which can be further analysed.

For some specific actions in my app I'm also tracking events like explained in the readme:
this.matomoTracker.trackEvent('Category', 'Action', 'Name', NumValue);

The missing cookies doesn't seem to be much of a problem, but I'll have to test this more when my app is live.

I'm not sure but I believe that setDocumentTitle() has to be called before trackPageView(), have you confirmed that you are calling them in the correct sequence?

I'm not using setDocumentTitle() and it works, so I don't think it's needed at all.

Hope this helps anyone. It may not be the full 100% integration, but it gives me more than enough data to analyse.

@Maqsyo
Copy link

@Maqsyo Maqsyo commented Mar 9, 2020

I think this page is really helpful for your cordova-app
https://developer.matomo.org/guides/spa-tracking

The question i have is -> how do you handle if the user is offline?
I'm thinking of saving the paq-array in an persistet file and collect all entries until the user has an connection again and hopefully matomo will clear this array if the connection was successfully.
Do you think this will work out?

@mattab
Copy link
Member Author

@mattab mattab commented Apr 20, 2020

The question i have is -> how do you handle if the user is offline?

@Maqsyo this will be a new feature that we need to implement in Matomo itself. Check our progress on #9939

@futuravis
Copy link

@futuravis futuravis commented Aug 6, 2021

I am facing issue with loading the motoma.js file. its working fine in angular web app. not in the ios ionic app.

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

Successfully merging a pull request may close this issue.

None yet
6 participants