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

Add row action to directly apply the current row as a segment (when browser archiving for segments is enabled) #14311

Open
Tolriq opened this issue Apr 3, 2019 · 16 comments
Labels
c: New plugin For features that probably will not be added to Matomo, but could be implemented as plugins.

Comments

@Tolriq
Copy link

Tolriq commented Apr 3, 2019

Currently testing Matomo and find it to be a wonderful project and evolution since Piwik 0.9 that I tested a very very very long time ago.

I currently have one big missing thing from Google Analytics, it's "down level" event navigation. (Sorry not native English don't know how to better describe).

Typically I'd like to be able to click on an event category then see all the actions from that category, then click on a action and see all names from that category and action.

Creating tons of manual segments are not really usable :( And I have many cases where I have identical action for different categories, so directly browsing from the event actions part is not an option either.

Do I miss something in the GUI? Or is it possible to make a feature request for that?

Edit by @tsteur : See conversation below. In #7215 we added an icon to the segmented visitor log, a plugin could however also add a row action to apply the segment directly without opening the segmented visitor log and without opening the edit segment screen after clicking on it.

@tsteur
Copy link
Member

tsteur commented Apr 3, 2019

There is likely already an issue for this but can't search right now. It can otherwise be done with https://plugins.matomo.org/CustomReports though.

@tsteur
Copy link
Member

tsteur commented Apr 3, 2019

Here is the issue: #7855

@tsteur tsteur added the duplicate For issues that already existed in our issue tracker and were reported previously. label Apr 3, 2019
@tsteur tsteur closed this as completed Apr 3, 2019
@Tolriq
Copy link
Author

Tolriq commented Apr 3, 2019

@tsteur

Did not get back up to that old on the search. And can't afford 200€ per year to use a feature 1 or 2 times a month :)

And actually this is not really the same need. I don't require a change of the display to see all at one. I'd like to have automatic custom segments when navigating down.

Adding a small button near open segmented visit log, that could be a simple add to current segment. That would add
&segment=eventCategory%3D%3DYYYYYY (or the ;eventCategory%3D%3DYYYYYY if there's already an active segment)

Then when clicking on an event action same thing that add to the segment the eventAction%3D%3DXXXX.

Sounds like a simple addition that would simplify user life a lot instead of tons of manual segments handling and editing.

@tsteur
Copy link
Member

tsteur commented Apr 3, 2019

When you click on "open segmented visit log", there is a button add the bottom to "add it as a current segment" maybe that helps you? Not sure why it's at the bottom as it requires a lot of scrolling but might still help?

@Tolriq
Copy link
Author

Tolriq commented Apr 3, 2019

@tsteur
Wow, well hidden feature, totally missed it. Thanks.

It does help to create the tons of saved segments, but on version 3.9.1 it does propose to create a new saved segment and require a name. So you'd have to first create a new segment for category then create a new one for the action. And they'd be saved and require manual deletion if it's a temporary segment (typically those descending event segment are often applied on another dynamic segment)

Since Matomo support an active custom segment (You can enter any segment param in url and it's properly supported and displayed as custom segment) maybe that add dialog could be modified by either adding an apply button near the save & apply, or when no name is entered instead of the error dialog, propose to apply the segment without saving it?
That would solve the issue for me, even with a tons of unneeded scrolling this would still be a perfect workaround.

@tsteur
Copy link
Member

tsteur commented Apr 3, 2019

To keep the UI simple we will likely not add another button or selector for this or so. Also it would only work if browser archiving for segments is enabled (most people should have it activated though). It would be possible to do this in a plugin though. I can rename and reopen the issue, and add a plugin label to it. I doubt we will be working on it though any time soon.

@tsteur tsteur changed the title Event navigation Add row action to directly apply the current row as a segment (when browser archiving for segments is enabled) Apr 3, 2019
@tsteur tsteur added c: New plugin For features that probably will not be added to Matomo, but could be implemented as plugins. and removed duplicate For issues that already existed in our issue tracker and were reported previously. labels Apr 3, 2019
@tsteur tsteur reopened this Apr 3, 2019
@Tolriq
Copy link
Author

Tolriq commented Apr 3, 2019

This is a huge limitation for users migrating from Google Analytics and with Google analytics for apps deprecated, and Firebase so limited for events, many people could try Matomo as a replacement, you certainly have something to play here, but for apps, events are one of the most important thing.

It's been a very long time since I've done some php but as it's an important feature for me, would it require a huge plugin or would it be relatively simple to implement, like just registering a few things to add a button in the rows then just a matter of filling the custom segment?

Else I'll write a simple SQL query tool to directly fetch from DB, but all I need is already here, just missing a way to link things.

@tsteur
Copy link
Member

tsteur commented Apr 4, 2019

I think you would mainly need a row action like this: https://github.com/matomo-org/matomo/blob/3.x-dev/plugins/Live/javascripts/rowaction.js#L14

Ideally you would also need to add a JS variable like piwik.isBrowserArchivingForSegmentsEnabled = true/false to the DOM like it is done here:

public function addJsGlobalVariables(&$out)
{
if (ProxyHttp::isHttps()) {
$isHttps = 'true';
} else {
$isHttps = 'false';
}
$out .= "piwik.hasServerDetectedHttps = $isHttps;\n";
}
as you should only show this feature when browser archiving for segments is actually enabled.

@Tolriq
Copy link
Author

Tolriq commented Apr 5, 2019

Ok thanks will look at that next week. Long time no PHP/JS will be fun.

I'll probably ping you if I have doubts about different solutions, to know what have the more chances to be accepted for plugin distribution as I'm sure it could help others.

@Tolriq
Copy link
Author

Tolriq commented Apr 8, 2019

@tsteur So got everything to work pretty easily, thanks for the pointers :)

I just have one issue with how to properly apply the segment change without a full reload of the page.
I searched a lot and can't find the proper way to just reload the content.

broadcast.propagateNewPage('segment='+segment, true)

Works but reload the full page so is slow and not nice UX :(

I tried propagateAjax but could not get it to work properly and it's deprecated anyway.

Looked into segmentation and found

// this code is mad, and may drive you mad.
// the whole segmentation editor needs to be rewritten in AngularJS with clean code

Since my js skills are limited I thought it was time to ask for help :)

Edit:
Getting back to it later, I've went the manual way, but I'm sure there's a proper one :)

        let dummyUrl = new URL('http://127.0.0.1');
        dummyUrl.search = window.location.hash.substring(2);
        dummyUrl.searchParams.set('segment', segment);
        window.location.hash = '?' + dummyUrl.searchParams;

@tsteur
Copy link
Member

tsteur commented Apr 8, 2019

Try something like this (that's what the segment editor seems to do):

 angular.element(document).injector().invoke(function ($location, $rootScope) {
                    var $search = $location.search();

                    if (segmentDefinition !== $search.segment) {
                        // eg when using back button the date might be actually already changed in the URL and we do not
                        // want to change the URL again
                        $search.segment = segmentDefinition.replace(/%$/, '%25').replace(/%([^\d].)/g, "%25$1");
                        $location.search($search);
                        setTimeout(function () {
                            try {
                                $rootScope.$apply();
                            } catch (e) {}
                        }, 1);
                    }
                });

@Tolriq
Copy link
Author

Tolriq commented Apr 9, 2019

Thanks since it's not an official function will keep my way easier to read way :)

I've pushed the plugin at https://github.com/Tolriq/Matomo-EventSegmentNavigation it works perfectly for my need, thanks again for the pointers.

Not sure this is advanced enough to warrant the trouble of going to through official release on the marketplace.

@tsteur
Copy link
Member

tsteur commented Apr 9, 2019

Had a quick look at the code. If you wanted to make it an official release, I would recommend changing hard coded URL https://github.com/Tolriq/Matomo-EventSegmentNavigation/blob/master/javascripts/rowaction.js#L76 and making it compatible with more browsers, not just those that support let etc. Great feature though :)

@Tolriq
Copy link
Author

Tolriq commented Apr 9, 2019

Was not sure about let my IDE told me to use them, I've revert :)

For the hardcoded url this is a dummy one not used, this allows to use native stuff to properly update the params in the url hash without regexp. I've added a comment.

To be perfect the plugin should move to the Actions when applying a category segment and stay in actions or move to names when applying an action filter, but had no time to fully research on those as it require to be applied after the page reload :(

@mattab
Copy link
Member

mattab commented Oct 7, 2019

@Tolriq Be great if you could publish your plugin on the Marketplace eventually, see: https://developer.matomo.org/guides/distributing-your-plugin - it's quite easy to do 👍

@Tolriq
Copy link
Author

Tolriq commented Oct 7, 2019

@mattab Sorry but no plan for that as it's not really usable in production with large data :( And when I officially publish things I provide support and won't be able for this.

The filters are insanely slow and timeout if not pre generated by the cron but those require to be added as static and wait for the cron.

Currently doing database SQL to get the data I need.

@mattab mattab added this to the Backlog (Help wanted) milestone Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: New plugin For features that probably will not be added to Matomo, but could be implemented as plugins.
Projects
None yet
Development

No branches or pull requests

3 participants