# Piwik: śledzenie asynchroniczne + logowanie ksywy komentującego w WordPress'ie

DevFeed: [Piwik: śledzenie asynchroniczne + logowanie ksywy komentującego w WordPress'ie](<https://devfeed.tech/articles/piwik-sledzenie-asynchroniczne-logowanie-ksywy-komentujacego-w-wordpress-ie-27561.md>)

Original publisher: [Read original article](<https://gagor.pro/2012/12/piwik-sledzenie-asynchroniczne-logowanie-ksywy-komentujacego-w-wordpressie/>)

Author: Tom

Published: 2012-12-21T00:00:00Z

Content type: tutorial

Language: pl

Sources: [Tomasz Gągor](<https://devfeed.tech/sources/tomasz-gagor.md>)

Topics: [WordPress](<https://devfeed.tech/topics/wordpress.md>), [async](<https://devfeed.tech/topics/async.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [analytics](<https://devfeed.tech/tags/analytics.md>), [async](<https://devfeed.tech/tags/async.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [defer](<https://devfeed.tech/tags/defer.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [js](<https://devfeed.tech/tags/js.md>), [script](<https://devfeed.tech/tags/script.md>), [wordpress](<https://devfeed.tech/tags/wordpress.md>)

## AI overview

This Polish developer article describes using Piwik with WordPress to track commenters based on the username or nickname stored in the comment field. It also shows how to load the Piwik tracking script asynchronously and set the commenter name as a custom variable.

## Source excerpt

Korzystam z instancji Piwik'a do monitorowania odwiedzin na stronie i postanowiłem pokombinować czy da się w ten sposób monitorować wejścia konkretnych osób na bazie wpisanego w polu komentarza loginu/ksywki. Jak zacząłem grzebać to przy okazji zmieniłem też sposób ładowania skryptów Piwika na asynchroniczny. A leci to mniej więcej tak: <script type="text/javascript"> var i,x,y,ARRcookies=document.cookie.split(";"); var comment_author = ""; for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x.indexOf("comment_author") != -1 && x.indexOf("comment_author_email") == -1 && x.indexOf("comment_author_url") == -1) { comment_author = unescape(y); } } var _paq = _paq || []; (function(){ var u=(("https:" == document.location.protocol) ? "https://url.instancji.piwika.pl/" : "http://url.instancji.piwika.pl/"); _paq.push(['setSiteId', 1]); _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setCustomVariable','1','Author', comment_author]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> Źródło http://piwik.org/docs/javascript-tracking/#toc-asynchronous-tracking external link http://codex.wordpress.org/WordPress_Cookies#Commenters external link