Forums » Help & Troubleshooting



How to track defined user

I like to track defined user inside database when it is logged in. How to set this?

If I do not have defined users, how to track visitor by cookie as cookie is defined and I like to see visitors path by cookie. Is this possible?

Posted Tue Oct 18 2011 1:30a by toplis***


Yes you can track usernames or anything else you want with a user who is logged in. You can read more here:

https://secure.getclicky.com/help/customization#session

Basically, you just create a single javascript variable that contains their username or other details. PHP example:

if( isset( $_SESSION['username'] )) {
  echo "
  <script>
  var clicky_custom = {};
  clicky_custom.username = '".$_SESSION['username']."'
  </script>";
}

That would need to go *above* the tracking code on your page.

Posted Wed Oct 19 2011 10:38p by Your Friendly Clicky Admin


Forgot to add a semi-color at the end of the clicky_custom.username line - it's not required but it's sloppy to not have it. Anyways, that should give you an idea.

Posted Wed Oct 19 2011 10:39p by Your Friendly Clicky Admin


Thank you.
1. What if I have cookie based website and not usernames in this moment?
2. Is correct to put under body tag?
3. Will script ECHO?
echo "

Posted Fri Oct 21 2011 2:58a by toplis***


Darn, I noticed another error in my example code. It's not "clicky_custom.username = {..}", it should be this:

clicky_custom.session = { username: '...' }

You can do it with cookies too... if( $_COOKIE['whatever'] ) ...

It can go anywhere in your code as long it's before our normal tracking code.

Not sure what you mean about the echo.

Posted Fri Oct 21 2011 9:44a by Your Friendly Clicky Admin


Is this built into the wordpress plugins at all?

Posted Mon Jan 13 2014 6:06p by jeffmac***


You must be logged in to your account to post!