Forums » Help & Troubleshooting



How can I dynamically add username to IP address

I'm using utm_content[username] and utm_content[email] in the URLs that I email to people on my list.

This automagically gets assigned to sessions when people come in on those links.

However, the next time they return, let's say directly and not from my custom URL, clicky does not retain the same username that they were assigned before.

So I guess what happens is that the *session* is assigned that username, but I want the *visitor* assigned the username, or maybe the IP address.

Or maybe they get a cookie, and even if their IP changes, their username remains the same.

How can I do this?

Thanks! :)

Posted Wed Nov 9 2011 1:08a by marshallso***


I meant utm_custom, not utm_content.

Posted Wed Nov 9 2011 1:27a by marshallso***


Yes it's only for the session. If you want persistent then you should set cookies based on those values, then declare them with custom data on returning session.

PHP example, setting cookies:

if( isset( $_GET['utm_custom'] )) {
  foreach( $_GET['utm_custom'] as $key => $value ) {
    set_cookie( "utm_custom[{$key}]", $value, time()+(86400*365), '/');
  }
}

Reading cookies (this would go ABOVE your tracking code so these values are output and read by our tracking code and then sent to us)

if( $_COOKIE['utm_custom'] ) {
  echo "<script>var clicky_custom = { username: {}};";
  foreach( $_COOKIE['utm_custom'] as $key => $value ) {
    echo "clicky_custom.username.{$key} = '$value';";
  }
  echo "</script>";
}

Posted Wed Nov 9 2011 8:10a by Your Friendly Clicky Admin


I didn't test the code so there might be a bug but that should be mostly right.

Posted Wed Nov 9 2011 8:11a by Your Friendly Clicky Admin


Does the code work?

Posted Sun Dec 28 2014 4:31p by japete***


You must be logged in to your account to post!