{"_id":"562014128a05d7230006ffd9","__v":6,"category":{"_id":"562014108a05d7230006ffae","pages":["562014128a05d7230006ffd8","562014128a05d7230006ffd9","562014128a05d7230006ffda","562014128a05d7230006ffdb","562014128a05d7230006ffdc","562014128a05d7230006ffdd","562014128a05d7230006ffde","562014128a05d7230006ffdf","562014128a05d7230006ffe0","562014128a05d7230006ffe1","562014128a05d7230006ffe2","562014128a05d7230006ffe3","562014128a05d7230006ffe4","562014128a05d7230006ffe5"],"project":"54861bb654b3ce0b00367292","version":"5620140f8a05d7230006ffac","__v":1,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-12-08T22:54:31.828Z","from_sync":false,"order":2,"slug":"2-personalization","title":"Cases & Dynamic Objects"},"parentDoc":null,"project":"54861bb654b3ce0b00367292","version":{"_id":"5620140f8a05d7230006ffac","project":"54861bb654b3ce0b00367292","__v":3,"createdAt":"2015-10-15T21:01:03.908Z","releaseDate":"2015-10-15T21:01:03.908Z","categories":["562014108a05d7230006ffad","562014108a05d7230006ffae","562014108a05d7230006ffaf","562014108a05d7230006ffb0","562014108a05d7230006ffb1","562014108a05d7230006ffb2","562014108a05d7230006ffb3","562014108a05d7230006ffb4","562014108a05d7230006ffb5","5666f7f5d784a70d00397bff","56967935b6d61f0d00acfb0b"],"is_deprecated":true,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"Moments","version_clean":"2.0.0","version":"2.0"},"user":"54861b9f3681d914006992a4","updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-12-09T10:07:54.733Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"never","params":[],"url":""},"isReference":false,"order":1,"body":"Elasticode enables you to create personalization by targeting specific users.  \nEach user will experience your app differently,   \nbased on cases which are defined in advance, and dynamic objects which can be changed in the dashboard.\n\nBut in order to do so you should first integrate it within your code.\n\n##**Defining A Case - Setting relevant hypotheses in advanced**  \nThe developer should define a case by:  \na) Name  \nb) Number of states within it.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Key\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description/Example\",\n    \"0-0\": \"Case name\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Indicate the name of the case you are defining, for example: \\\"Login button\\\"\",\n    \"1-2\": \"A number indicating the probable number of options for this specific case\",\n    \"1-0\": \"numberOfStates\",\n    \"1-1\": \"Integer\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Before \\\"starting a session\\\"\",\n  \"body\": \"This method should be initiated before starting a new session\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[ElastiCode defineCase: :::at:::\\\"First Button\\\" withNumOfStates: 3];\",\n      \"language\": \"objectivec\",\n      \"name\": null\n    },\n    {\n      \"code\": \"ElastiCode .defineCase(\\\"First Button\\\", withNumOfStates: 3)\",\n      \"language\": \"objectivec\",\n      \"name\": \"Swift\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"A quick note before we move on... We can use cases ONLY after sync\",\n  \"body\": \"Remember, you could only use the personalization capability of cases only after the sync was finished.\"\n}\n[/block]\n#**Using Cases**\nOnce reaching a decision point, We fire the `stateIndexForCase` method that retrieves the relevant answer for your decision point, i.e.: what to display? what option to choose? should we display or not? and alike...\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Key\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description/Example\",\n    \"0-0\": \"CaseName\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Indicate the name of the case you are defining, for example: \\\"Login button\\\"\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"switch ([ElastiCode stateIndexForCase:@\\\"First Button\\\"]){\\n  case 1:\\n\\t  b1.backgroundColor = [UIColor cyanColor];\\n  \\tbreak;\\n  case 2:\\n\\t  b1.backgroundColor = [UIColor magentaColor];\\n  \\tbreak;\\n  case 0:\\n  default:\\n  \\tb1.backgroundColor = [UIColor yellowColor];\\n\\t  break;\\n}\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"switch (ElastiCode .stateIndexForCase(\\\"First Button\\\")){\\n  case 1:\\n\\t  b1.backgroundColor = UIColor.cyanColor()\\n    break;\\n  case 2:\\n  \\tb1.backgroundColor = UIColor.magentaColor()\\n    break;\\n  case 0:\\n  default:\\n\\t  b1.backgroundColor = UIColor.yellowColor()\\n    break;\\n}\",\n      \"language\": \"objectivec\",\n      \"name\": \"Swift\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Optional\",\n  \"body\": \"In case you are loading the data before using it, follow these two steps:\"\n}\n[/block]\nA) Get the selected state index of a case.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"int index = [ElastiCode stateIndexWithoutVisitForCase:@\\\"Buy Button\\\"];\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"let index = ElastiCode .stateIndexWithoutVisitForCase(\\\"Buy Button\\\")\",\n      \"language\": \"objectivec\",\n      \"name\": \"Swift\"\n    }\n  ]\n}\n[/block]\nB) Once a case is visible to an end user, alert our server about it:\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Key\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description/Example\",\n    \"0-0\": \"caseName\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Name of the relevant case you would like to alert about\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[ElastiCode visitCase:@\\\"Buy Button\\\"];\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"ElastiCode .visitCase(\\\"Buy Button\\\")\",\n      \"language\": \"objectivec\",\n      \"name\": \"Swift\"\n    }\n  ]\n}\n[/block]\n##**Reaching a goal**\nIn order to optimise your app we need to know what is the desired action of each case, and from that to understand the conversion rate of each alternative. \nThe desired action should be defined within the code by the developer and may be a click (e.g. for the “Buy button”), \na swipe or even the fact that a user had not left the screen for 2 minutes (if you desire for retention).  \nAs said, it can be anything of your choice... \n\nTo update elasticode about a successful action, use:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[ElastiCode goalReached:@\\\"Buy Button\\\"];\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"ElastiCode .goalReached(\\\"Buy Button\\\")\",\n      \"language\": \"objectivec\",\n      \"name\": \"Swift\"\n    }\n  ]\n}\n[/block]","excerpt":"Building cases and, their relevant states, visits and actions","slug":"cases","type":"basic","title":"Creating Cases"}

Creating Cases

Building cases and, their relevant states, visits and actions

Elasticode enables you to create personalization by targeting specific users. Each user will experience your app differently, based on cases which are defined in advance, and dynamic objects which can be changed in the dashboard. But in order to do so you should first integrate it within your code. ##**Defining A Case - Setting relevant hypotheses in advanced** The developer should define a case by: a) Name b) Number of states within it. [block:parameters] { "data": { "h-0": "Key", "h-1": "Type", "h-2": "Description/Example", "0-0": "Case name", "0-1": "String", "0-2": "Indicate the name of the case you are defining, for example: \"Login button\"", "1-2": "A number indicating the probable number of options for this specific case", "1-0": "numberOfStates", "1-1": "Integer" }, "cols": 3, "rows": 2 } [/block] [block:callout] { "type": "warning", "title": "Before \"starting a session\"", "body": "This method should be initiated before starting a new session" } [/block] [block:code] { "codes": [ { "code": "[ElastiCode defineCase: @\"First Button\" withNumOfStates: 3];", "language": "objectivec", "name": null }, { "code": "ElastiCode .defineCase(\"First Button\", withNumOfStates: 3)", "language": "objectivec", "name": "Swift" } ] } [/block] [block:callout] { "type": "info", "title": "A quick note before we move on... We can use cases ONLY after sync", "body": "Remember, you could only use the personalization capability of cases only after the sync was finished." } [/block] #**Using Cases** Once reaching a decision point, We fire the `stateIndexForCase` method that retrieves the relevant answer for your decision point, i.e.: what to display? what option to choose? should we display or not? and alike... [block:parameters] { "data": { "h-0": "Key", "h-1": "Type", "h-2": "Description/Example", "0-0": "CaseName", "0-1": "String", "0-2": "Indicate the name of the case you are defining, for example: \"Login button\"" }, "cols": 3, "rows": 1 } [/block] [block:code] { "codes": [ { "code": "switch ([ElastiCode stateIndexForCase:@\"First Button\"]){\n case 1:\n\t b1.backgroundColor = [UIColor cyanColor];\n \tbreak;\n case 2:\n\t b1.backgroundColor = [UIColor magentaColor];\n \tbreak;\n case 0:\n default:\n \tb1.backgroundColor = [UIColor yellowColor];\n\t break;\n}", "language": "objectivec" }, { "code": "switch (ElastiCode .stateIndexForCase(\"First Button\")){\n case 1:\n\t b1.backgroundColor = UIColor.cyanColor()\n break;\n case 2:\n \tb1.backgroundColor = UIColor.magentaColor()\n break;\n case 0:\n default:\n\t b1.backgroundColor = UIColor.yellowColor()\n break;\n}", "language": "objectivec", "name": "Swift" } ] } [/block] [block:callout] { "type": "warning", "title": "Optional", "body": "In case you are loading the data before using it, follow these two steps:" } [/block] A) Get the selected state index of a case. [block:code] { "codes": [ { "code": "int index = [ElastiCode stateIndexWithoutVisitForCase:@\"Buy Button\"];", "language": "objectivec" }, { "code": "let index = ElastiCode .stateIndexWithoutVisitForCase(\"Buy Button\")", "language": "objectivec", "name": "Swift" } ] } [/block] B) Once a case is visible to an end user, alert our server about it: [block:parameters] { "data": { "h-0": "Key", "h-1": "Type", "h-2": "Description/Example", "0-0": "caseName", "0-1": "String", "0-2": "Name of the relevant case you would like to alert about" }, "cols": 3, "rows": 1 } [/block] [block:code] { "codes": [ { "code": "[ElastiCode visitCase:@\"Buy Button\"];", "language": "objectivec" }, { "code": "ElastiCode .visitCase(\"Buy Button\")", "language": "objectivec", "name": "Swift" } ] } [/block] ##**Reaching a goal** In order to optimise your app we need to know what is the desired action of each case, and from that to understand the conversion rate of each alternative. The desired action should be defined within the code by the developer and may be a click (e.g. for the “Buy button”), a swipe or even the fact that a user had not left the screen for 2 minutes (if you desire for retention). As said, it can be anything of your choice... To update elasticode about a successful action, use: [block:code] { "codes": [ { "code": "[ElastiCode goalReached:@\"Buy Button\"];", "language": "objectivec" }, { "code": "ElastiCode .goalReached(\"Buy Button\")", "language": "objectivec", "name": "Swift" } ] } [/block]