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

capture custom log param(s); capture only records with custom param(s) #5252

Closed
fogelfish opened this issue May 27, 2014 · 3 comments
Closed
Labels
duplicate For issues that already existed in our issue tracker and were reported previously. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@fogelfish
Copy link

It would be nice for import_logs.py to be able to make one or more custom log parameters into Piwik custom variables and hand them to the Piwik Tracking API request.

I am completely new to Piwik but I will see if I can solve this on my own. I'm not sure of protocol would it be okay to post questions as I work on this?

@fogelfish
Copy link
Author

I'm following up on Matt's idea of supplying a custom --log-format-regex that includes a custom parameter. I'm wondering how Piwik would know about the new custom parameter.

In PHP one would declare it this way:

#!div style="font-size: 80%"

#!php
piwikTracker.setCustomVariable(1, "VisitorType", "Member", "visit");
piwikTracker.trackPageView();

In Javascript this way:

#!div style="font-size: 80%"

#!javascript
_paq.push(['setCustomVariable','1','VisitorType','Member']);
_paq.push([ function() { var customVariable = this.getCustomVariable(1); }]);

The regex captures the parameter. An example log line includes the parameter: uname=anabella1234

#!div style="font-size: 80%"

#!python
(?:uname=)(?P<username>\S+)

Does the parameter have to be explicitly declared to be a CustomVariable in the Python request? Can the CustomVariable be defined in the Piwik configuration rather than be declared in the Python script? Would the a _cvar array have to be piggy-backed with the request?

I'm unsure of the mechanism to bind the parameter in Python to a custom variable in Piwik, but I just need a nudge in the right direction.

@mattab
Copy link
Member

mattab commented Jun 2, 2014

What I would try to achieve, is to first capture the parameter as you point out, and once captured, to append it to the request URL, eg. &cvar= which is a JSON value containing your custom variable username. Does it make sense?

@fogelfish fogelfish added this to the 2.x - The Great Piwik 2.x Backlog milestone Jul 8, 2014
@mattab mattab removed the P: normal label Aug 3, 2014
@mattab mattab added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. and removed Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. labels Oct 11, 2014
@mattab mattab modified the milestones: Mid term, Long term Oct 11, 2014
@mattab
Copy link
Member

mattab commented Mar 12, 2015

Issue was moved to the new repository for Piwik Log Analytics: https://github.com/piwik/piwik-log-analytics/issues

refs #7163

@mattab mattab closed this as completed Mar 12, 2015
@mattab mattab added the duplicate For issues that already existed in our issue tracker and were reported previously. label Mar 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate For issues that already existed in our issue tracker and were reported previously. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

2 participants