{"action":"created","issue":{"url":"https://api.github.com/repos/segmentio/analytics.js-core/issues/34","repository_url":"https://api.github.com/repos/segmentio/analytics.js-core","labels_url":"https://api.github.com/repos/segmentio/analytics.js-core/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/segmentio/analytics.js-core/issues/34/comments","events_url":"https://api.github.com/repos/segmentio/analytics.js-core/issues/34/events","html_url":"https://github.com/segmentio/analytics.js-core/issues/34","id":210185246,"number":34,"title":"Setting custom `campaign` properties","user":{"login":"SpainTrain","id":380032,"avatar_url":"https://avatars2.githubusercontent.com/u/380032?v=4","gravatar_id":"","url":"https://api.github.com/users/SpainTrain","html_url":"https://github.com/SpainTrain","followers_url":"https://api.github.com/users/SpainTrain/followers","following_url":"https://api.github.com/users/SpainTrain/following{/other_user}","gists_url":"https://api.github.com/users/SpainTrain/gists{/gist_id}","starred_url":"https://api.github.com/users/SpainTrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpainTrain/subscriptions","organizations_url":"https://api.github.com/users/SpainTrain/orgs","repos_url":"https://api.github.com/users/SpainTrain/repos","events_url":"https://api.github.com/users/SpainTrain/events{/privacy}","received_events_url":"https://api.github.com/users/SpainTrain/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-02-24T23:28:58Z","updated_at":"2017-08-09T14:01:27Z","closed_at":"2017-03-09T20:32:11Z","body":"Hello.  I cannot seem to get custom campaign properties sent in `context` for a `page` call.\r\n\r\nHere is the code on the page:\r\n\r\n```js\r\n!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error(\"Segment snippet included twice.\");else{analytics.invoked=!0;analytics.methods=[\"trackSubmit\",\"trackClick\",\"trackLink\",\"trackForm\",\"pageview\",\"identify\",\"reset\",\"group\",\"track\",\"ready\",\"alias\",\"debug\",\"page\",\"once\",\"off\",\"on\"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement(\"script\");e.type=\"text/javascript\";e.async=!0;e.src=(\"https:\"===document.location.protocol?\"https://\":\"http://\")+\"cdn.segment.com/analytics.js/v1/\"+t+\"/analytics.min.js\";var n=document.getElementsByTagName(\"script\")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION=\"4.0.0\";\r\n\tanalytics.load(\"<key>\");\r\n\r\n\tfunction getQueryVariable(variable) {\r\n    \tvar query = window.location.search.substring(1);\r\n    \tvar vars = query.split(\"&\");\r\n    \tfor (var i=0;i<vars.length;i++) {\r\n        \tvar pair = vars[i].split(\"=\");\r\n        \tif(pair[0] == variable){return pair[1];}\r\n    \t}\r\n    \treturn(void 0);\r\n\t}\r\n\r\n\tvar campaign = {\r\n        name: getQueryVariable(\"ctx_campaign\"),\r\n        source: getQueryVariable(\"ctx_source\"),\r\n        medium: getQueryVariable(\"ctx_medium\"),\r\n        term: getQueryVariable(\"ctx_term\"),\r\n        content: getQueryVariable(\"ctx_content\")\r\n    }\r\n\r\n\twindow.console && window.console.log && window.console.log('campaign', campaign)\r\n\r\n\tanalytics.page({}, {\r\n      \tcontext: {campaign: campaign},\r\n     \tcampaign: campaign\r\n\t});\r\n}}();\r\n```\r\n\r\nThe campaign object prints correctly to the console. However, the API call does not include `campaign`:\r\n\r\n```\r\n{\r\n  \"context\": {\r\n    \"campaign\": {\r\n      \r\n    },\r\n    \"page\": {\r\n      \"path\": \"\\/offer\",\r\n      \"referrer\": \"\",\r\n      \"search\": \"?ctx_source=spaintrain&ctx_term=spain,train&ctx_campaign=spainzy\",\r\n      \"title\": \"[Pricing - Step 1] Pricing.Full.Length.1.20\",\r\n      \"url\": \"http:\\/\\/pricing-analysis.myhomezen.com\\/offer?ctx_source=spaintrain&ctx_term=spain,train&ctx_campaign=spainzy\"\r\n    },\r\n    \"userAgent\": \"Mozilla\\/5.0 (X11; Linux x86_64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/56.0.2924.87 Safari\\/537.36\",\r\n    \"library\": {\r\n      \"name\": \"analytics.js\",\r\n      \"version\": \"3.0.0\"\r\n    }\r\n  },\r\n  \"integrations\": {\r\n    \r\n  },\r\n  \"properties\": {\r\n    \"path\": \"\\/offer\",\r\n    \"referrer\": \"\",\r\n    \"search\": \"?ctx_source=spaintrain&ctx_term=spain,train&ctx_campaign=spainzy\",\r\n    \"title\": \"[Pricing - Step 1] Pricing.Full.Length.1.20\",\r\n    \"url\": \"http:\\/\\/pricing-analysis.myhomezen.com\\/offer?ctx_source=spaintrain&ctx_term=spain,train&ctx_campaign=spainzy\"\r\n  },\r\n  \"category\": null,\r\n  \"name\": null,\r\n  \"anonymousId\": \"be16ec17-7f10-4f70-9072-df5491ce78ec\",\r\n  \"timestamp\": \"2017-02-24T23:25:04.878Z\",\r\n  \"type\": \"page\",\r\n  \"writeKey\": \"<key>\",\r\n  \"userId\": \"<id>\",\r\n  \"sentAt\": \"2017-02-24T23:25:04.881Z\",\r\n  \"_metadata\": {\r\n    \"bundled\": [\r\n      \"AdRoll\",\r\n      \"Amplitude\",\r\n      \"Facebook Pixel\",\r\n      \"Google Analytics\",\r\n      \"Google Tag Manager\",\r\n      \"Lucky Orange\",\r\n      \"Mixpanel\",\r\n      \"Segment.io\"\r\n    ],\r\n    \"unbundled\": [\r\n      \r\n    ]\r\n  },\r\n  \"messageId\": \"ajs-55423f6e71370b8998553bd7d25c2009\"\r\n}\r\n```\r\n\r\nIt is possible to see this live at https://pricing-analysis.myhomezen.com/offer?ctx_source=spaintrain&ctx_term=spain,train&ctx_campaign=spainzy\r\n\r\nIt seems to be supported, because I updated the page event test like so and it still passes:\r\n\r\n```js\r\n    it('should accept top level option .context', function() {\r\n      var app = { name: 'segment' };\r\n      var campaign = { name: 'segment' };\r\n      analytics.page({ prop: true }, { context: { app: app, campaign: campaign } });\r\n      var page = analytics._invoke.args[0][1];\r\n      assert.deepEqual(app, page.obj.context.app);\r\n      assert.deepEqual(campaign, page.obj.context.campaign);\r\n    });\r\n```\r\n\r\nIs this intended to be supported?  If so, pointers on where to look next to find the issue?"},"comment":{"url":"https://api.github.com/repos/segmentio/analytics.js-core/issues/comments/321264222","html_url":"https://github.com/segmentio/analytics.js-core/issues/34#issuecomment-321264222","issue_url":"https://api.github.com/repos/segmentio/analytics.js-core/issues/34","id":321264222,"user":{"login":"zsherman","id":1152279,"avatar_url":"https://avatars3.githubusercontent.com/u/1152279?v=4","gravatar_id":"","url":"https://api.github.com/users/zsherman","html_url":"https://github.com/zsherman","followers_url":"https://api.github.com/users/zsherman/followers","following_url":"https://api.github.com/users/zsherman/following{/other_user}","gists_url":"https://api.github.com/users/zsherman/gists{/gist_id}","starred_url":"https://api.github.com/users/zsherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zsherman/subscriptions","organizations_url":"https://api.github.com/users/zsherman/orgs","repos_url":"https://api.github.com/users/zsherman/repos","events_url":"https://api.github.com/users/zsherman/events{/privacy}","received_events_url":"https://api.github.com/users/zsherman/received_events","type":"User","site_admin":false},"created_at":"2017-08-09T14:01:27Z","updated_at":"2017-08-09T14:01:27Z","body":"Not sure if something changed but this still doesn't work for me using the latest analytics.js"}}
{"actor":{"display_login":"zsherman"}}