{"id":285,"date":"2015-04-07T18:30:00","date_gmt":"2015-04-07T18:30:00","guid":{"rendered":"\/blog\/blog\/mixpanel_tracking_in_angularjs.html"},"modified":"2015-04-07T18:30:00","modified_gmt":"2015-04-07T18:30:00","slug":"mixpanel-tracking-in-angularjs","status":"publish","type":"post","link":"https:\/\/mohammedlakkadshaw.com\/blog\/mixpanel-tracking-in-angularjs.html","title":{"rendered":"Mixpanel Tracking in AngularJS"},"content":{"rendered":"<p>For my recent angularJS application, I needed to integrate Mixpanel.<br \/>\nI didn\u2019t found any light-weight directives which I could include in the application that would allow me to easily track events using Mixpanel in the application, so I built Mixular.<br \/>\nMixualr is a lightweight angularJS directive which you can use to track events in your application.<\/p>\n<h2 id=\"installation\">Installation<\/h2>\n<p>You can install mixular via bower<\/p>\n<div class=\"highlighter-rouge\">\n<pre class=\"highlight\"><code>\tbower install mixular\n<\/code><\/pre>\n<\/div>\n<p>Or you can clone the repo from <a href=\"https:\/\/github.com\/mlakkadshaw\/Mixular\">Github<\/a><\/p>\n<h2 id=\"how-to-use-it\">How to use it<\/h2>\n<p>To use mixular in your application include the Mixpanel javascript tracking library, and the <code class=\"highlighter-rouge\">angular-mixular-directive.js<\/code> in your index.html<\/p>\n<p>Then add mixular dependency in your AngularJS application:<\/p>\n<div class=\"highlighter-rouge\">\n<pre class=\"highlight\"><code>var app = angular.module(\u201cyourApp\u201d, [\u201cmixular-directive\u201d]);\n<\/code><\/pre>\n<\/div>\n<p>Once you have added the dependency, you can start tracking events in your application, e.g:<\/p>\n<div class=\"highlighter-rouge\">\n<pre class=\"highlight\"><code><a href=\u201c#\/feedback\u201d mixular=\u201cclick\u201d eventLabel=\u201cFeedback Clicked\u201d prop-user=\u201cJames\u201d>Feedback<\/a>\t\n<\/code><\/pre>\n<\/div>\n<p>Add the property <code class=\"highlighter-rouge\">mixular<\/code> and specify the events on which you want to trigger the tracking, supported event types are:<\/p>\n<ul>\n<li>click<\/li>\n<li>focus\n<ol>\n<li>hover<\/li>\n<li>keydown<\/li>\n<li>keypress<\/li>\n<li>keyup<\/li>\n<li>mousedown<\/li>\n<li>mouseenter<\/li>\n<li>mouseleave<\/li>\n<li>mouseout<\/li>\n<li>mouseover<\/li>\n<li>mouseup<\/li>\n<li>scroll<\/li>\n<li>select<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p>The <code class=\"highlighter-rouge\">eventLabel<\/code> can be used to specify a label for the event e.g \u201cBanner Ad clicked\u201d.<\/p>\n<h3 id=\"passing-properties\">Passing properties<\/h3>\n<p>To pass multiple properties for a event you can type the keyword prop followed by the property name e.g <code class=\"highlighter-rouge\">prop-product=\u201cLaptop\u201d prop-price=\u201c500\u201d<\/code><\/p>\n<h3 id=\"thats-all\">That\u2019s all<\/h3>\n<p>If you have any questions or suggestions regarding the directive, leave them in the comment section below.<\/p>\n<p>Thanks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For my recent angularJS application, I needed to integrate Mixpanel. I didn\u2019t found any light-weight directives which I could include in the application that would allow me to easily track events using Mixpanel in the application, so I built Mixular. Mixualr is a lightweight angularJS directive which you can use to track events in your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-285","post","type-post","status-publish","format-standard","hentry","category-angularjs"],"_links":{"self":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/posts\/285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/comments?post=285"}],"version-history":[{"count":0,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/posts\/285\/revisions"}],"wp:attachment":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/media?parent=285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/categories?post=285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/tags?post=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}