matomo-org / matomo-sdk-ios

Matomo iOS, tvOS and macOS SDK: a Matomo tracker written in Swift
MIT License
388 stars 164 forks source link

Event tracking: remove "example.com" url. #194

Closed ferenclakos closed 7 years ago

ferenclakos commented 7 years ago

Hi!

I would like use the event tracking but have a problem.

We can see the events on the dashboard but we would like remove the "example.com" url from actions. As I have seen it has been hard coded into source code.

event_tracking_problem

Could you please provide a possibility to change this url?

Thanks.

rdani91 commented 7 years ago

We have this similar problem too. Our system requires to set a specific domain, but we couldn't find the possibility to do that.

thbaja commented 7 years ago

You can create your own custom events where you can set the URL as described here.

But it would be nice to be able to set a base URL once, maybe in configureSharedInstance (not to be confused with the baseURL tracking endpoint).And then screen names would use this url as the base when tracking page views (PiwikTracker.shared?.track(view: ["path","to","your","page"]))

And similar behaviour when tracking events. Ie. the url sent with the event would be this base url, along with optional screen names.

YvesCandel commented 7 years ago

Is the URL necessary? I would rather just leave it empty/null by default... the Android SDK works like that it seems.

brototyp commented 7 years ago

I think the easiest way for now would be to add a url parameter to the event tracking function. This would be consistent with tracking a view (where you can already do that).

Additionally I like the idea of defining the "http://example.com" once and we use it to generate the url if none is given.

As described here the url is a required field. @mattab Is this really the case? Is it possible to ditch the url since in most/some cases one on mobile there aren't urls matching the content in the app?

YvesCandel commented 7 years ago

We're seeing this from our Android app:

screen shot 2017-10-12 at 09 42 44

...and this from our iOS app:

screen shot 2017-10-12 at 09 42 52

This somehow makes me doubt that the url is a required field...

mattab commented 7 years ago

@brototyp Turns out in reality the URL is not required and actually optional. Fixed the developer documentation in: https://github.com/piwik/developer-documentation/pull/195

You can therefore make it optional in the SDK :+1:

brototyp commented 7 years ago

Hi @mattab, great news. Then the only question is, if we want to keep the "auto url generation"-method, or if it can be defined per view- oder event-tracking and be not set per default. I think I like the latter most, since the default mechanism will probably very rarely be correct.

mattab commented 7 years ago

It would be helpful in general to be consistent between SDKs, especially with Android SDK so the generated data is similar. ->Can you define the current "auto url generation" - how does it work and how helpful is it?

brototyp commented 7 years ago

That is a good point. As far as I can see, the Android SDK derives the base url from the app identifier and then uses the action path as the url path. Currently we do the same, but use "example.com" as base url. We could, without an issue, do the same in the iOS SDK.

Still, I am not sure if we should go this way. This only makes sense, if the action path in the app is semantically the same as the url path. I don't think it makes sense to expect that as a default.

mattab commented 7 years ago

Still, I am not sure if we should go this way. This only makes sense, if the action path in the app is semantically the same as the url path. I don't think it makes sense to expect that as a default.

What would be the alternatives? (IMHO the option "No url" at all is not useful, so wondering if there are other options)

Otherwise sounds good to use same technique as the Android SDK ("derive the base url from the app identifier")

brototyp commented 7 years ago

I am thinking the other way round: What information do we want to add, when we add a URL to a tracked view or event. From an app's perspective, the only thing I can see (please correct me if I am wrong) is to match a certain app-content to a content that is also available on the web.

If we generate a url from data that we push to the server anyways (for example if the path is generated from the action segments), we don't add any information and there will be barely a case where the autogenerated url matches a real content from the web. I this case I think there is no use in just sending "some url".

Am I wrong here with my thoughts?

thbaja commented 7 years ago

Agreed, I think most use cases is to match app-content with web-content.

And when doing event tracking, it would be nice to be able to just pass in an 'An array of hierarchical screen names' as is the case with screen view tracking. Preferably without having to enter a base url everytime, since that doesn't change.

brototyp commented 7 years ago

What do you think about the following plan: We start by merging this pull request: #195

It simply removes the example.com domain. And in a different Ticket we sketch out if we want to have automatic url generation and the necessities for it.

brototyp commented 7 years ago

The implementation was merged and is part of the next release.

brototyp commented 7 years ago

I just found out that the backed behaves differently from what I thought, especially for page views. I changed my proposal here: #197. I am open for different views on the topic.