{"_id":"560ca0517048021700e180e6","category":"560c9d9399bb5a0d0044f220","editedParams2":true,"isReference":true,"link_url":"","version":"560c93ae7e9b9d0d00ca81a5","sync_unique":"","__v":0,"api":{"examples":{"codes":[{"language":"javascript","code":"Attribution.track(event, [properties], [callback]);","name":""}]},"results":{"codes":[]},"settings":"","auth":"required","params":[{"name":"event","in":"body","_id":"560ca0517048021700e180e9","required":true,"desc":"The name of the event","default":"","type":"string"},{"desc":"A hashtable of properties describing the event.","default":"","type":"object","name":"properties","in":"body","_id":"560ca0517048021700e180e8","required":false},{"type":"object","name":"callback","in":"body","_id":"560ca0517048021700e180e7","required":false,"desc":"A callback function that gets called after a short timeout.","default":""}],"url":"/Attribution.track(event, [properties], [callback]);"},"body":"[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Attribution.track(event, [properties], [callback]);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"**event** \\n*String*\",\n    \"0-1\": \"The name of the event\",\n    \"1-0\": \"**properties** \\n*Object, optional*\",\n    \"1-1\": \"A hashtable of properties describing the event.\",\n    \"2-1\": \"A callback function that gets called after a short timeout.\",\n    \"2-0\": \"**callback** \\n*Object, optional*\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Defining your Funnel\"\n}\n[/block]\nThese events should describe the action taken in a way that would be recognizable to anyone in your company. Here’s some good examples of funnel events:\n\nSAAS Funnel: Created Account, Completed Account Setup, Entered Credit Card, Purchased Subscription.\n\nShopping Cart Funnel: Added Item to Cart, Viewed Cart, Entered Credit Card, Completed Purchase.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Sending Properties Along With Events\"\n}\n[/block]\nTrack allows you to send properties along with your events. We recommend sending meaningful properties along with your events to color the event with details of what happened. Here are some examples of the kind of properties you may want to send with a conversion event like Made a Purchase:\n\nOrder Total, Subscription Plan, Items In Cart, Number of Licenses\n\nMaking a call to track call is easy, a call to track must have an event name and can include optional array of properties. In this case we see a Converted event with the 'package' property set to 'pro'\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Attribution.track('Converted', {\\n  package: 'pro'\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Special Properties for Track: Revenue\"\n}\n[/block]\nAttribution recognizes the revenue property on the track event and stores it in a special way. Revenue should be passed in the format [dollars].[cents] or 79.99 – just as it’s commonly written. Here’s an example of an event with the revenue property:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Attribution.track('Credit Card Charged', {\\n  revenue: '79.99'\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Track Link\"\n}\n[/block]\nSometimes you need to track a link that will cause a page reload before the tracking call can be completed. In this case you want to use trackLink. trackLink will wait to load the page until a callback is received from Attribtuion or timeout has expired. The Attribution timout deaults to 100ms.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<div id=\\\"checkout\\\">\\n    <a href=\\\"/checkout\\\">Checkout</a>\\n</div>\\n<script type=\\\"text/javascript\\\">\\n    Attribution.trackLink(\\\"#checkout\\\", \\\"Click Checkout\\\");\\n</script>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Track Form\"\n}\n[/block]\ntrackForm works the same way as trackLink by delaying the page reload and allowing the the tracking call to complete.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var createAccountForm = document.getElementById('createAccountForm');\\n\\nAttribution.trackForm(createAccountForm, 'Created Account', {\\n  Package: 'Enterprice',\\n  Seats: 28\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","editedParams":true,"githubsync":"","order":0,"parentDoc":null,"title":"Track","createdAt":"2015-10-01T02:54:09.629Z","hidden":false,"project":"560c93ad7e9b9d0d00ca81a2","excerpt":"Track is used to record events. You should use this method to record each step of your conversion funnel.","link_external":false,"slug":"track","type":"fn","updates":[],"user":"560c92f2ac2859170013faa3","childrenPages":[]}

Track

Track is used to record events. You should use this method to record each step of your conversion funnel.

[block:code] { "codes": [ { "code": "Attribution.track(event, [properties], [callback]);", "language": "javascript" } ] } [/block] [block:parameters] { "data": { "0-0": "**event** \n*String*", "0-1": "The name of the event", "1-0": "**properties** \n*Object, optional*", "1-1": "A hashtable of properties describing the event.", "2-1": "A callback function that gets called after a short timeout.", "2-0": "**callback** \n*Object, optional*" }, "cols": 2, "rows": 3 } [/block] [block:api-header] { "type": "basic", "title": "Defining your Funnel" } [/block] These events should describe the action taken in a way that would be recognizable to anyone in your company. Here’s some good examples of funnel events: SAAS Funnel: Created Account, Completed Account Setup, Entered Credit Card, Purchased Subscription. Shopping Cart Funnel: Added Item to Cart, Viewed Cart, Entered Credit Card, Completed Purchase. [block:api-header] { "type": "basic", "title": "Sending Properties Along With Events" } [/block] Track allows you to send properties along with your events. We recommend sending meaningful properties along with your events to color the event with details of what happened. Here are some examples of the kind of properties you may want to send with a conversion event like Made a Purchase: Order Total, Subscription Plan, Items In Cart, Number of Licenses Making a call to track call is easy, a call to track must have an event name and can include optional array of properties. In this case we see a Converted event with the 'package' property set to 'pro' [block:code] { "codes": [ { "code": "Attribution.track('Converted', {\n package: 'pro'\n});", "language": "javascript" } ] } [/block] [block:api-header] { "type": "basic", "title": "Special Properties for Track: Revenue" } [/block] Attribution recognizes the revenue property on the track event and stores it in a special way. Revenue should be passed in the format [dollars].[cents] or 79.99 – just as it’s commonly written. Here’s an example of an event with the revenue property: [block:code] { "codes": [ { "code": "Attribution.track('Credit Card Charged', {\n revenue: '79.99'\n});", "language": "javascript" } ] } [/block] [block:api-header] { "type": "basic", "title": "Track Link" } [/block] Sometimes you need to track a link that will cause a page reload before the tracking call can be completed. In this case you want to use trackLink. trackLink will wait to load the page until a callback is received from Attribtuion or timeout has expired. The Attribution timout deaults to 100ms. [block:code] { "codes": [ { "code": "<div id=\"checkout\">\n <a href=\"/checkout\">Checkout</a>\n</div>\n<script type=\"text/javascript\">\n Attribution.trackLink(\"#checkout\", \"Click Checkout\");\n</script>", "language": "html" } ] } [/block] [block:api-header] { "type": "basic", "title": "Track Form" } [/block] trackForm works the same way as trackLink by delaying the page reload and allowing the the tracking call to complete. [block:code] { "codes": [ { "code": "var createAccountForm = document.getElementById('createAccountForm');\n\nAttribution.trackForm(createAccountForm, 'Created Account', {\n Package: 'Enterprice',\n Seats: 28\n});", "language": "javascript" } ] } [/block]