Include only certian URL text

Is there a way to only have Piwik track downloads or import only downloads from the log files?

you can first “grep” the download extensions from your log and only import these lines that contain a download file.

I tried doing the following command with the grep, but the import_logs.py seems to run indefinitely.

/usr/local/bin/python /import_logs.py --url=https:///piwik --idsite=1 --add-sites-new-hosts grep -R '\.pdf' access_log

otherwise, a solution is to first create the log file with only the downloads (with cat file | egrep “pdf|htm” > log-to-import then import it)

Does the import script expect the log to be in a certain format?

For example, if the grep out put is set to a variable in a bash script, can that variable be used as the input (log)?

the script expects logs in a certain format. sorry I dont understand your question.

#!/bin/bash

grepTxt=grep -R '\.pdf' /access_log

/usr/local/bin/python /piwik/misc/log-analytics/import_logs.py --url=[IP]/piwik --idsite=1 $grepTxt

For that script, the ‘grepTxt’ variable is being passed in as the log input (as if access.log was there instead). Is that sort of output from the variable not the expected input for the log?

the script expects Files, not strings