{"_id":"55f1b2be7dccfc0d00986b72","__v":4,"category":{"_id":"55f1970339e3e8190068b2b8","pages":["55f1a1e6229b772300779a34","55f1b11b39e3e8190068b2f1","55f1b59b39e3e8190068b2fc","55f1b6215fe76419007dc760","55f1b69539e3e8190068b2fe","55f1b90a5fe76419007dc763","55f1b93ffd98c42300acc643"],"project":"55de06fa57f7b20d0097636b","version":"55de06fa57f7b20d0097636e","__v":7,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-10T14:43:15.288Z","from_sync":false,"order":2,"slug":"android-sdk","title":"Android SDK"},"user":"55de06e19db51a0d0064947d","project":"55de06fa57f7b20d0097636b","version":{"_id":"55de06fa57f7b20d0097636e","project":"55de06fa57f7b20d0097636b","__v":14,"createdAt":"2015-08-26T18:35:38.642Z","releaseDate":"2015-08-26T18:35:38.642Z","categories":["55de06fb57f7b20d0097636f","55f1962e3936d52d00fb3c8f","55f1970339e3e8190068b2b8","55f1970d229b772300779a1f","55f1971cfd98c42300acc605","55f1d5c7fd98c42300acc69f","563cbfe4260dde0d00c5e9d4","5644cf437f1fff210078e690","57dc1bbd3ed3450e00dc9ea7","58a600a2243dd30f00fd8773","58ed1bdc068f780f00f64602","58f13b3a4f0ee50f00e24e81","58f173f792f9020f009cad16","591b42f8e633fd0f00077c5a"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-10T16:41:34.713Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"PushSpring's segmentation functionality allows you to easily group users by what actions they take within your application.  The following methods are available on the **PushSpring.sharedPushSpring()** object for recording additional information about your app users.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Increase Customer Lifetime Value\"\n}\n[/block]\nIncrease the stored Customer Lifetime Value for this user, for later segmentation. This value is sent in cents, i.e. if the user makes an in-app purchase for $1.99, you should send [NSNumber numberWithInt:199].\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public void increaseCustomerLifetimeValue(final int cents);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Set Customer Id\"\n}\n[/block]\nIf your app has a customer identifier (perhaps a user id that identifies the user to a backend server), you can associate it with the current user in the PushSpring dashboard.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public void setCustomerId(final String customerId);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Set Customer Birth Year\"\n}\n[/block]\nIf you know the users' birth year, you can send it to us here.  It should be the full four digit year.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public void setCustomerBirthYear(final Integer birthYear);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Set Customer Gender\"\n}\n[/block]\nIf your app is connected to Facebook or knows the users' gender, you can send it to us here.  There are predefined PS_GENDER_MALE and PS_GENDER_FEMALE values to send in.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public void setCustomerGender(final String gender);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Set Location\"\n}\n[/block]\nAttempt to retrieve the users' location.  Note that this method will NOT result in a user being prompted to allow your app access to location information; it checks to see if your app is already authorized, and if so, sends the data to PushSpring.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public void setAvailableLocationInfo();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Set Latitude and Longitude\"\n}\n[/block]\nIf you have a latitude and longitude for the user, you can record it here for later location-based segmentation on the PushSpring dashboard.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public void setLocation(final double latitude, final double longitude);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Record Event\"\n}\n[/block]\nRecord a custom event for later segmentation.  For instance, you might store that the user has completed Level 9 in a game, or that they've viewed a particular area of content.  These custom events will be displayed in the segment editor on the PushSpring dashboard.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public void recordEvent(final String eventName);\\npublic void recordEvent(final String eventName, final int increasedBy);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"custom-events-and-attributes-a","type":"basic","title":"Recording Your App's Events and Attributes"}

Recording Your App's Events and Attributes


PushSpring's segmentation functionality allows you to easily group users by what actions they take within your application. The following methods are available on the **PushSpring.sharedPushSpring()** object for recording additional information about your app users. [block:api-header] { "type": "basic", "title": "Increase Customer Lifetime Value" } [/block] Increase the stored Customer Lifetime Value for this user, for later segmentation. This value is sent in cents, i.e. if the user makes an in-app purchase for $1.99, you should send [NSNumber numberWithInt:199]. [block:code] { "codes": [ { "code": "public void increaseCustomerLifetimeValue(final int cents);", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Set Customer Id" } [/block] If your app has a customer identifier (perhaps a user id that identifies the user to a backend server), you can associate it with the current user in the PushSpring dashboard. [block:code] { "codes": [ { "code": "public void setCustomerId(final String customerId);", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Set Customer Birth Year" } [/block] If you know the users' birth year, you can send it to us here. It should be the full four digit year. [block:code] { "codes": [ { "code": "public void setCustomerBirthYear(final Integer birthYear);", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Set Customer Gender" } [/block] If your app is connected to Facebook or knows the users' gender, you can send it to us here. There are predefined PS_GENDER_MALE and PS_GENDER_FEMALE values to send in. [block:code] { "codes": [ { "code": "public void setCustomerGender(final String gender);", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Set Location" } [/block] Attempt to retrieve the users' location. Note that this method will NOT result in a user being prompted to allow your app access to location information; it checks to see if your app is already authorized, and if so, sends the data to PushSpring. [block:code] { "codes": [ { "code": "public void setAvailableLocationInfo();", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Set Latitude and Longitude" } [/block] If you have a latitude and longitude for the user, you can record it here for later location-based segmentation on the PushSpring dashboard. [block:code] { "codes": [ { "code": "public void setLocation(final double latitude, final double longitude);", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Record Event" } [/block] Record a custom event for later segmentation. For instance, you might store that the user has completed Level 9 in a game, or that they've viewed a particular area of content. These custom events will be displayed in the segment editor on the PushSpring dashboard. [block:code] { "codes": [ { "code": "public void recordEvent(final String eventName);\npublic void recordEvent(final String eventName, final int increasedBy);", "language": "java" } ] } [/block]