-def piwik_url(**kw):
- url = settings.PIWIK_URL + u"/piwik.php?"
- url += u'&'.join([k + u"=" + str(v) for k, v in kw.items()])
- logger.info("piwik url: %s" % url)
- return url
+def piwik_url(request):
+ return urllib.urlencode(dict(
+ idsite=_id_piwik,
+ rec=1,
+ url='http://%s%s' % (request.META['HTTP_HOST'], request.path),
+ rand=int(random() * 0x10000),
+ apiv=PIWIK_API_VERSION,
+ urlref=request.META.get('HTTP_REFERER', ''),
+ ua=request.META.get('HTTP_USER_AGENT', ''),
+ lang=request.META.get('HTTP_ACCEPT_LANGUAGE', ''),
+ token_auth=getattr(settings, 'PIWIK_TOKEN', ''),
+ cip=request.META['REMOTE_ADDR'],
+ cdt=datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
+ ))