Skip to content

Instantly share code, notes, and snippets.

@sud0n1m
Created April 27, 2012 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sud0n1m/2512743 to your computer and use it in GitHub Desktop.
Save sud0n1m/2512743 to your computer and use it in GitHub Desktop.
/* This should work well. We'll use the "plan" variable. When a user signs up it will be blank.
* When they complete the process, it should be "Premium" or whatever you would call your plan.
* Using the created at date, we'll send users an email X days after signup if the plan is blank.
*/
<script type="text/javascript">
var _cio = _cio || [];
(function() {
var a,b,c;a=function(f){return function(){_cio.push([f].
concat(Array.prototype.slice.call(arguments,0)))}};b=["identify",
"track"];for(c=0;c<b.length;c++){_cio[b[c]]=a(b[c])};
var t = document.createElement('script'),
s = document.getElementsByTagName('script')[0];
t.async = true;
t.id = 'cio-tracker';
t.setAttribute('data-site-id', 'YOUR SITE ID HERE');
t.src = 'https://app.customer.io/assets/track.js';
s.parentNode.insertBefore(t, s);
})();
/* Only display this if your users are logged in. This is in Ruby */
<% if user_signed_in? %>
_cio.identify({
id: 'production_34', // must be unique per customer
email: 'customer@example.com',
created_at: 1333688268, // seconds since the epoch (January 1, 1970)
name: 'Joe',
plan: 'premium'
});
<% end %>
/* this ends the ruby conditional */
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment