{"_id":"560c93b07e9b9d0d00ca81a8","link_url":"","title":"Attribution for Developers: Installing Attribution","type":"basic","api":{"auth":"required","params":[],"results":{"codes":[]},"settings":"","url":""},"body":"Attribution has three calls that need to be installed properly page(), identify(), and track(). Page() or 'the snippet' must be installed on the client side of all of your customer facing pages. Page() will set an anonymous_id cookie for visitors and create a visits on the dashboard.  When a visitor submits a webform or identifies themselves you should call identify() this will replace the anonymous_id with unique traits like name && email or a unique user_id from intercom or your companies database. Finally to tie this all together and calculate return on ad spend track() should be called whenever you want to track a conversion event like sign up, or order paid, you can track anything the marketing team would like to see return on ad spend for. Track() with a revenue property will be used to calculate return on ad spend on the dashboard. **If you use Segment or Heap or Shopify you're in luck and Attribution will just tap right into your current data structure. ** check out the articles to the left to learn more about that. \n\nAttribution offers integrations with Wordpress & Hubspot for page(), identify(), and revenue() if all your events occur on Wordpress or Hubspot pages. \n\nBelow is a very simple life cycle of a visit and where each call should be placed. Landing page and Web form Submitted are track() or conversion events, these can be virtually anything you'd like to see return on ad spend for including sign ups, order paid or started a subscription etc. \n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/f2aab98-Screen_Shot_2020-07-17_at_6.51.49_PM.png\",\n        \"Screen Shot 2020-07-17 at 6.51.49 PM.png\",\n        688,\n        564,\n        \"#212121\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Install the Snippet\"\n}\n[/block]\nAttribution  between the <head></head> HTML on your pages. The code below is an example, but you can find your team's tracking snippet by going to the [settings page here](https://dashboard.attributionapp.com/v1/#!/settings) \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<script type=\\\"text/javascript\\\">\\nwindow.Attribution=window.Attribution||[];window.Attribution.methods=[\\\"trackSubmit\\\",\\\"trackClick\\\",\\\"trackLink\\\",\\\"trackForm\\\",\\\"pageview\\\",\\\"identify\\\",\\\"group\\\",\\\"track\\\",\\\"ready\\\",\\\"alias\\\",\\\"page\\\",\\\"once\\\",\\\"off\\\",\\\"on\\\"];window.Attribution.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);window.Attribution.push(t);return window.Attribution}};for(var i=0;i<window.Attribution.methods.length;i++){var key=window.Attribution.methods[i];window.Attribution[key]=window.Attribution.factory(key)}window.Attribution.load=function(e){if(document.getElementById(\\\"attribution-js\\\"))return;var t=document.createElement(\\\"script\\\");t.type=\\\"text/javascript\\\";t.id=\\\"attribution-js\\\";t.async=true;t.src=\\\"//scripts.attributionapp.com/attribution.js\\\";var n=document.getElementsByTagName(\\\"script\\\")[0];n.parentNode.insertBefore(t,n)};window.Attribution.load();\\nwindow.Attribution.projectId=\\\"[[app:key]]\\\";\\nwindow.Attribution.page();\\n</script> \",\n      \"language\": \"html\"\n    },\n    {\n      \"code\": \"window.Attribution=window.Attribution||[];window.Attribution.methods=[\\\"trackSubmit\\\",\\\"trackClick\\\",\\\"trackLink\\\",\\\"trackForm\\\",\\\"pageview\\\",\\\"identify\\\",\\\"group\\\",\\\"track\\\",\\\"ready\\\",\\\"alias\\\",\\\"page\\\",\\\"once\\\",\\\"off\\\",\\\"on\\\"];window.Attribution.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);window.Attribution.push(t);return window.Attribution}};for(var i=0;i<window.Attribution.methods.length;i++){var key=window.Attribution.methods[i];window.Attribution[key]=window.Attribution.factory(key)}window.Attribution.load=function(e){if(document.getElementById(\\\"attribution-js\\\"))return;var t=document.createElement(\\\"script\\\");t.type=\\\"text/javascript\\\";t.id=\\\"attribution-js\\\";t.async=true;t.src=\\\"//scripts.attributionapp.com/attribution.js\\\";var n=document.getElementsByTagName(\\\"script\\\")[0];n.parentNode.insertBefore(t,n)};window.Attribution.load();\\nwindow.Attribution.projectId=\\\"YOUR_PROJECT_ID\\\";\\nwindow.Attribution.page();\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nWhen you paste the snippet, you'll need to change YOUR_APP_KEY to the project id listed in the [settings](https://dashboard.attributionapp.com/#!/settings) page.\n\nThe snippet will create an anonymous_id for the visitor and use this to continue tracking until the visitor identifies themselves. \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Identify Users\"\n}\n[/block]\n`identify` is used to link a users actions and pageviews to a recognizable name or email address. You'll need to identify whenever a user identifies themselves, this includes sign up, log in, subscribe etc. \n\nWhen calling identify() you should pass in a userid field from your universal database. Then you can  provide email address, name, and anything else you'd like as a trait.  You can provide as many customer traits as you'd like to save.\n\nBe sure to include 'createdAt' as a trait so you can later distinguish between new and existing users. \n\nIf you **do not have a universal userid** you should omit the userid field and provide name and email as traits. \n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Attribution.identify('00812938', {\\n  name: 'Bob Slydell', \\n  email: 'bob:::at:::initech.co'\\n  createdAt: new Date()\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Track Events\"\n}\n[/block]\nTrack is used to record events. You should use this method to record each step of your conversion funnel. 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:\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\nAttribution app recognizes the revenue property on the track event and stores it in a special way. 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\": \"4. Creating filters\"\n}\n[/block]\nNow that the tracking is in place, you'll need to think about your filters. Attribution works by tracking the referring domains & destination domains of a visitor. A referring domain is the domain that the visitor came from like www.google.com or www.facebook.com, while the destination domain is the \npage your visitor lands on and includes parameters, check out the example below where the URL parameters would be /get_attribution/ and fbaid=12318. Attribution will filter by these parameters to assign credit to ads for visits. \n\n**https://www.attributionapp.com**/get_attribution/fbaid=12318** **\n\nYou can easily integrate with Facebook, Google Ads, Twitter, Ad roll, Bing, and LinkedIn to allow attribution to automatically tag your ads with a unique a attribution parameter. See spend tracking integrations to the left for more. \n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/a348ed1-Screen_Shot_2020-07-17_at_7.16.22_PM.png\",\n        \"Screen Shot 2020-07-17 at 7.16.22 PM.png\",\n        830,\n        576,\n        \"#303030\"\n      ]\n    }\n  ]\n}\n[/block]","excerpt":"This page will help you get started with Attribution. You'll be up and running in a jiffy!","githubsync":"","project":"560c93ad7e9b9d0d00ca81a2","version":"560c93ae7e9b9d0d00ca81a5","link_external":false,"next":{"description":"","pages":[]},"hidden":false,"isReference":false,"order":0,"parentDoc":null,"slug":"getting-started","__v":10,"category":"560c93af7e9b9d0d00ca81a6","createdAt":"2015-10-01T02:00:16.038Z","sync_unique":"","updates":[],"user":"560c92f2ac2859170013faa3","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Attribution for Developers: Installing Attribution

This page will help you get started with Attribution. You'll be up and running in a jiffy!

Attribution has three calls that need to be installed properly page(), identify(), and track(). Page() or 'the snippet' must be installed on the client side of all of your customer facing pages. Page() will set an anonymous_id cookie for visitors and create a visits on the dashboard. When a visitor submits a webform or identifies themselves you should call identify() this will replace the anonymous_id with unique traits like name && email or a unique user_id from intercom or your companies database. Finally to tie this all together and calculate return on ad spend track() should be called whenever you want to track a conversion event like sign up, or order paid, you can track anything the marketing team would like to see return on ad spend for. Track() with a revenue property will be used to calculate return on ad spend on the dashboard. **If you use Segment or Heap or Shopify you're in luck and Attribution will just tap right into your current data structure. ** check out the articles to the left to learn more about that. Attribution offers integrations with Wordpress & Hubspot for page(), identify(), and revenue() if all your events occur on Wordpress or Hubspot pages. Below is a very simple life cycle of a visit and where each call should be placed. Landing page and Web form Submitted are track() or conversion events, these can be virtually anything you'd like to see return on ad spend for including sign ups, order paid or started a subscription etc. [block:image] { "images": [ { "image": [ "https://files.readme.io/f2aab98-Screen_Shot_2020-07-17_at_6.51.49_PM.png", "Screen Shot 2020-07-17 at 6.51.49 PM.png", 688, 564, "#212121" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "1. Install the Snippet" } [/block] Attribution between the <head></head> HTML on your pages. The code below is an example, but you can find your team's tracking snippet by going to the [settings page here](https://dashboard.attributionapp.com/v1/#!/settings) [block:code] { "codes": [ { "code": "<script type=\"text/javascript\">\nwindow.Attribution=window.Attribution||[];window.Attribution.methods=[\"trackSubmit\",\"trackClick\",\"trackLink\",\"trackForm\",\"pageview\",\"identify\",\"group\",\"track\",\"ready\",\"alias\",\"page\",\"once\",\"off\",\"on\"];window.Attribution.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);window.Attribution.push(t);return window.Attribution}};for(var i=0;i<window.Attribution.methods.length;i++){var key=window.Attribution.methods[i];window.Attribution[key]=window.Attribution.factory(key)}window.Attribution.load=function(e){if(document.getElementById(\"attribution-js\"))return;var t=document.createElement(\"script\");t.type=\"text/javascript\";t.id=\"attribution-js\";t.async=true;t.src=\"//scripts.attributionapp.com/attribution.js\";var n=document.getElementsByTagName(\"script\")[0];n.parentNode.insertBefore(t,n)};window.Attribution.load();\nwindow.Attribution.projectId=\"[[app:key]]\";\nwindow.Attribution.page();\n</script> ", "language": "html" }, { "code": "window.Attribution=window.Attribution||[];window.Attribution.methods=[\"trackSubmit\",\"trackClick\",\"trackLink\",\"trackForm\",\"pageview\",\"identify\",\"group\",\"track\",\"ready\",\"alias\",\"page\",\"once\",\"off\",\"on\"];window.Attribution.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);window.Attribution.push(t);return window.Attribution}};for(var i=0;i<window.Attribution.methods.length;i++){var key=window.Attribution.methods[i];window.Attribution[key]=window.Attribution.factory(key)}window.Attribution.load=function(e){if(document.getElementById(\"attribution-js\"))return;var t=document.createElement(\"script\");t.type=\"text/javascript\";t.id=\"attribution-js\";t.async=true;t.src=\"//scripts.attributionapp.com/attribution.js\";var n=document.getElementsByTagName(\"script\")[0];n.parentNode.insertBefore(t,n)};window.Attribution.load();\nwindow.Attribution.projectId=\"YOUR_PROJECT_ID\";\nwindow.Attribution.page();", "language": "javascript" } ] } [/block] When you paste the snippet, you'll need to change YOUR_APP_KEY to the project id listed in the [settings](https://dashboard.attributionapp.com/#!/settings) page. The snippet will create an anonymous_id for the visitor and use this to continue tracking until the visitor identifies themselves. [block:api-header] { "type": "basic", "title": "2. Identify Users" } [/block] `identify` is used to link a users actions and pageviews to a recognizable name or email address. You'll need to identify whenever a user identifies themselves, this includes sign up, log in, subscribe etc. When calling identify() you should pass in a userid field from your universal database. Then you can provide email address, name, and anything else you'd like as a trait. You can provide as many customer traits as you'd like to save. Be sure to include 'createdAt' as a trait so you can later distinguish between new and existing users. If you **do not have a universal userid** you should omit the userid field and provide name and email as traits. [block:code] { "codes": [ { "code": "Attribution.identify('00812938', {\n name: 'Bob Slydell', \n email: '[email protected]'\n createdAt: new Date()\n});", "language": "javascript" } ] } [/block] [block:api-header] { "type": "basic", "title": "3. Track Events" } [/block] Track is used to record events. You should use this method to record each step of your conversion funnel. 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. Attribution app recognizes the revenue property on the track event and stores it in a special way. 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": "4. Creating filters" } [/block] Now that the tracking is in place, you'll need to think about your filters. Attribution works by tracking the referring domains & destination domains of a visitor. A referring domain is the domain that the visitor came from like www.google.com or www.facebook.com, while the destination domain is the page your visitor lands on and includes parameters, check out the example below where the URL parameters would be /get_attribution/ and fbaid=12318. Attribution will filter by these parameters to assign credit to ads for visits. **https://www.attributionapp.com**/get_attribution/fbaid=12318** ** You can easily integrate with Facebook, Google Ads, Twitter, Ad roll, Bing, and LinkedIn to allow attribution to automatically tag your ads with a unique a attribution parameter. See spend tracking integrations to the left for more. [block:image] { "images": [ { "image": [ "https://files.readme.io/a348ed1-Screen_Shot_2020-07-17_at_7.16.22_PM.png", "Screen Shot 2020-07-17 at 7.16.22 PM.png", 830, 576, "#303030" ] } ] } [/block]