Recognizing ActionKit Users with sticky-akid.js

The user-recognition system in ActionKit is primarily focused on tokens called AKIDs that are automatically included in the links included by the mailings sent out from the platform. (There is a separate login system based on passwords and session cookies, but it is only used in a limited number of cases, such as changing recurring donations.)

This system works great for users who are taking action directly from a mailing, but falls short if they visit your site directly, or follow links on social media, or browse around after taking one action and decide they want to take another — in these cases, ActionKit will fail to recognize the user, and require them to re-enter their email address, name, and location data.

Introducing sticky-akid.js

To overcome this limitation, I developed a small JavaScript library named sticky-akid.js which retains the user’s identity information between visits to ActionKit forms.

The sticky value is kept in the browser’s localStorage rather than a cookie. The only value that’s stored is an AKID, reducing the privacy and security risks; no personal information is saved or transmitted.

[Postscript, November 26:] The sticky-akid.js library is now available on GitHub.

How It Works

The sticky-akid.js code hooks into ActionKit standard actionkit.js code in three places — beforeSubmit, getArgs, and logOut — adding additional bits of code that run before or after the built-in functionality.

When a user arrives at an ActionKit form without an AKID query string parameter and without a sticky AKID value saved from a previous visit, they’re shown a regular form as usual, with the addition of a “remember me” checkbox or equivalent user-interface element. (Depending on your needs and audience profile, this could be opt-in or could default to being enabled.)

After the user submits the form, if sticky-akid.js notices that that the checkbox is present and checked, it will store a local timestamp in the browser to note that it is currently in “remember me” mode.

After the form submission is processed, ActionKit redirects the user to a “thanks” screen, passing along an AKID associated with the user’s identity. If this happens less than ten seconds after the user has requested “remember me,” this new AKID is added to the local storage.

The next time the user visits an ActionKit form without an AKID query parameter, the value from local storage will be retrieved and used to recognize the user.

If the user clicks the “Not you? Click here.” link, the stored value is cleared and the form is reloaded so the user is no longer recognized and new name and email address values can be entered.

Integration

To add this capability to your ActionKit instance:

  • Include sticky-akid.js in the head of your wrapper.html template so that it’s loaded on every ActionKit page.
  • In your user forms, include a checkbox input with the name remember-me and an appropriate label that tells users they should not use this feature on shared computer such as in a library or internet cafe.

The script tag in wrapper.html should look something like this, although you might prefer to make your own copy of the JavaScript library and host it elsewhere:

<script src="https://greenthumbsoftware.com/akjs/sticky-akid.js"></script>

The remember-me checkbox might be included in user_form.html and could use markup similar to this:

<div> 
	<label> <input type="checkbox" name="remember-me" value="1" checked> Remember me </label>
	<br> (Don't use this on a shared computer.)
</div>

Conclusion

This capability reduces the need for people to repeatedly enter their names and addresses in ActionKit forms, potentially increasing action rates.

I developed this technique while working for WeMove Europe; my thanks to them for allowing me to publish it here.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *