Skip to content

Instantly share code, notes, and snippets.

@fedek6
Created June 5, 2018 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedek6/60b88d24958bd249e78d59b9b24d6e07 to your computer and use it in GitHub Desktop.
Save fedek6/60b88d24958bd249e78d59b9b24d6e07 to your computer and use it in GitHub Desktop.
Bat for importing Matomo logs on Windows enviroment.
@echo off
:: Based on https://matomo.org/docs/log-analytics-tool-how-to/
:: Global config
:: Python URL (must be 2.x)
SET PY_BIN=C:\Program Files\Python\Python27\python.exe
:: Matomo import_logs executable
SET IMPORT_LOGS=C:\inetpub\htdocs\piwik\misc\log-analytics\import_logs.py
:: IIS log dir
SET LOGS_DIR=C:\inetpub\logs\LogFiles
:: Access token from Piwik config
SET TOKEN=*********************************
:: URL to your Piwik installation
SET URL=http://yourstats.org
:: CPU threads
SET THREADS=2
:: Change this according to your system locale.
:: Current setting is based on dd.mm.yyyy format (Poland)
SET DAY=%date:~0,2%
SET MONTH=%date:~3,2%
SET YEAR=%date:~8,2%
:: First website
:: @Adrianu: This part should be imported from matomo.json file
SET DIR=W3SVC3
SET ID=1
:: Automatically generated vars
SET LOG_FILE=u_ex%YEAR%%MONTH%%DAY%.log
SET LOG_PATH=%LOGS_DIR%\%DIR%\%LOG_FILE%
:: Run command
"%PY_BIN%" "%IMPORT_LOGS%" --url=%URL% --idsite=%ID% --token-auth=%TOKEN% --recorders=%THREADS% --enable-http-errors --enable-http-redirects --enable-static --enable-bots "%LOG_PATH%"
@echo Parsed log file: %LOG_PATH%
[
{"id":1, "dir":"W3SVC3", "name":"www.mnw.art.pl"}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment