@pjs13 opened this Issue on February 26th 2016

Hi,

I am using centos and have installed piwik in it.
I want to validate user's login on my website html page.
So my 1st page is test1.html and 2nd page will be test2.html.

I tried with using document.getElementById to capture the username from test1.html to test2.html like
Test1.html
<form action="test2.html>" onsubmit="MyFunction()" >
<input type="text" name="username" id="username"/>
<input type="submit" name="Login"/>
</form><script>
function MyFunction() { var username= document.getElementById("username"); }
Test2.html :
var _paq = _paq || []; _paq.push(['getUserId',username]); // _paq.push(['getUserId','"username'"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); `

even after doing this i am getting the username.
Plz help me to how to validate userlogin name.

@tsteur commented on February 26th 2016 Owner

I'm not sure what you mean by validating?

Possibly it is because of a type maybe. Can you try to remove the > in action="test2.html>".

_paq.push(['getUserId',username]); won't do anything as we do not save the username across requests. Maybe you want to call setUserId? In test2.html also make sure username is actually set.

@pjs13 commented on February 29th 2016

ya thanks for the replying.

Actually i need to get the value of username in my next page(page2.html). Where piwik stores that user_id in database and i get the username in my piwik plugin, where i have written a query to display user_Id. i.e select user_id from piwik_log_visit;

& if i remove form action then,how can i redirect to next page??

@tsteur commented on March 6th 2016 Owner

I'm sorry but I don't really understand what you are trying to achieve. AFAIK it is not possible to get the username on the next page via piwik.js. Actually, you kind of have to set the username on each request instead so piwik will always use the same username across requests of a specific user.

I'm not sure if a custom "Piwik plugin" can help you there either as Piwik won't really know which user it is when you query the API. Maybe try to store the username in a session or cookie within your regular application/website, then on each page request call _paq.push(['setUserId',usernameFromSessionOrCookieOr...]);.

This Issue was closed on March 6th 2016
Powered by GitHub Issue Mirror