Skip to content

Instantly share code, notes, and snippets.

@jelukas
Created September 22, 2016 08:49
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 jelukas/7e5a3ec6b56a2a292bb0a26150ce56ce to your computer and use it in GitHub Desktop.
Save jelukas/7e5a3ec6b56a2a292bb0a26150ce56ce to your computer and use it in GitHub Desktop.
base.html - fragment , thisis in base html so it used in all templates (Django).
{% if request.user.is_authenticated %}
<!-- Customer.io Tracking -->
<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=["load","identify",
"sidentify","track","page"];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', '{{ customerio_site_id }}');
t.src = 'https://assets.customer.io/assets/track.js';
s.parentNode.insertBefore(t, s);
})();
</script>
<script type="text/javascript">
_cio.identify({
// Required attributes
id: '{{ request.user.id }}', // Unique id for the currently signed in user in your application.
email: '{{ request.user.email }}' // Email of the currently signed in user.
});
</script>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment