{"__v":21,"_id":"552d67163e1c280d00f76422","category":{"__v":5,"_id":"5564cb5c1fd04c0d00dc9a40","pages":["5564cba6f0f70f0d00a9aadb","5564cbb11fd04c0d00dc9a41","5564cbf31fd04c0d00dc9a43","55b0034ad7624e3700e4fb94","55b031e8f202b12100cda16b"],"project":"552d67153e1c280d00f7641c","version":"552d67153e1c280d00f7641f","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-05-26T19:37:00.006Z","from_sync":false,"order":9999,"slug":"marin-ios-sdk","title":"Marin iOS SDK"},"project":"552d67153e1c280d00f7641c","user":"552d66b53e1c280d00f7641b","version":{"__v":3,"_id":"552d67153e1c280d00f7641f","project":"552d67153e1c280d00f7641c","createdAt":"2015-04-14T19:14:29.744Z","releaseDate":"2015-04-14T19:14:29.744Z","categories":["552d67163e1c280d00f76420","5564cb5c1fd04c0d00dc9a40","5568ec5ec87afd2500e52598"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-14T19:14:30.893Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"## Installation\n\nHere is how to import the Marin iOS SDK into your app \n\n1. Setup CocoaPods (dependency management for iOS apps) if you have not already. [See guide here](https://guides.cocoapods.org/terminal/commands.html#group_installation).\n2. [Download the SDK](https://perfect-audience-mobile.s3.amazonaws.com/ios-sdk/Marin_iOS_SDK_1.0.0.zip) to your computer.\n3. Open a terminal and navigate to your project directory.\n4. Create a Podfile in your project if you don't have one already. [See guide here](https://guides.cocoapods.org/terminal/commands.html#group_installation).\n5. Reference the Marin iOS SDK in your Podfile\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pod 'Marin-iOS-SDK', path: '../path/to/unzipped/Marin iOS SDK directory'\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\n*Note: The SDK currently supports iOS 6.0 and later. Please be sure your application targets an iOS platform version equal to or greater than 6.0.*\n\nYour Podfile should look similar to this:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"source 'https://github.com/CocoaPods/Specs'\\n\\nplatform :ios, '6.0'\\n\\npod 'Marin-iOS-SDK', path: '../path/to/unzipped/Marin iOS SDK directory'\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\n6. Run this command in your projects directory in a terminal console\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ pod install\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nto add the Marin iOS SDK to your workspace.\n\n\n## Setup\n\n\n1. Import the header of the SDK into your project. To do this, we recommend importing the Marin SDK into your AppDelegate.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <Marin-iOS-SDK/Marin.h>\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n2. Next, look up the \"Advertiser ID\" for the advertiser you want the SDK to talk to in your Perfect Audience account.  You can find the Advertiser ID by visiting the \"User Tracking\" page in your \"Manage\" navigation tab and looking at the top right of the User Tracking page\n\n3. Next, initialize the SDK by executing the following code snippet using the Advertiser ID from the previous step with the `didFinishLaunchingWithOptions` method in your AppDelegate.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[Marin start::::at:::\\\"< advertiser id goes here >\\\"];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n4. Now that the SDK is installed and initialized, you will begin tracking app opens. \n\n\n## Commands\n\n\nHere is how to track an **event**. By Tracking this event this will create a related \n**segment**. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[Marin trackEvent:@\\\"event1\\\" withMetadata:nil];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nHere is how to track a **product viewing**:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[Marin trackProductView:@\\\"product1\\\" withMetadata:nil]; \\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nAnd here is how to track an event with the extra data needed for a **conversion**. Conversions need to be setup in the app to read these events.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[Marin trackEvent:@\\\"Purchase\\\"\\n       withOrderId:@\\\"12345\\\"\\n           revenue:@\\\"19.99\\\"\\nconversionMetadata:nil\\n          metadata:nil];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","excerpt":"Everything you need to start building audiences and tracking conversions in your apps.","slug":"getting-started","type":"basic","title":"Getting Started with Marin iOS SDK"}

Getting Started with Marin iOS SDK

Everything you need to start building audiences and tracking conversions in your apps.

## Installation Here is how to import the Marin iOS SDK into your app 1. Setup CocoaPods (dependency management for iOS apps) if you have not already. [See guide here](https://guides.cocoapods.org/terminal/commands.html#group_installation). 2. [Download the SDK](https://perfect-audience-mobile.s3.amazonaws.com/ios-sdk/Marin_iOS_SDK_1.0.0.zip) to your computer. 3. Open a terminal and navigate to your project directory. 4. Create a Podfile in your project if you don't have one already. [See guide here](https://guides.cocoapods.org/terminal/commands.html#group_installation). 5. Reference the Marin iOS SDK in your Podfile [block:code] { "codes": [ { "code": "pod 'Marin-iOS-SDK', path: '../path/to/unzipped/Marin iOS SDK directory'", "language": "ruby" } ] } [/block] *Note: The SDK currently supports iOS 6.0 and later. Please be sure your application targets an iOS platform version equal to or greater than 6.0.* Your Podfile should look similar to this: [block:code] { "codes": [ { "code": "source 'https://github.com/CocoaPods/Specs'\n\nplatform :ios, '6.0'\n\npod 'Marin-iOS-SDK', path: '../path/to/unzipped/Marin iOS SDK directory'", "language": "ruby" } ] } [/block] 6. Run this command in your projects directory in a terminal console [block:code] { "codes": [ { "code": "$ pod install", "language": "shell" } ] } [/block] to add the Marin iOS SDK to your workspace. ## Setup 1. Import the header of the SDK into your project. To do this, we recommend importing the Marin SDK into your AppDelegate. [block:code] { "codes": [ { "code": "#import <Marin-iOS-SDK/Marin.h>", "language": "objectivec" } ] } [/block] 2. Next, look up the "Advertiser ID" for the advertiser you want the SDK to talk to in your Perfect Audience account. You can find the Advertiser ID by visiting the "User Tracking" page in your "Manage" navigation tab and looking at the top right of the User Tracking page 3. Next, initialize the SDK by executing the following code snippet using the Advertiser ID from the previous step with the `didFinishLaunchingWithOptions` method in your AppDelegate. [block:code] { "codes": [ { "code": "[Marin start:@\"< advertiser id goes here >\"];", "language": "objectivec" } ] } [/block] 4. Now that the SDK is installed and initialized, you will begin tracking app opens. ## Commands Here is how to track an **event**. By Tracking this event this will create a related **segment**. [block:code] { "codes": [ { "code": "[Marin trackEvent:@\"event1\" withMetadata:nil];", "language": "objectivec" } ] } [/block] Here is how to track a **product viewing**: [block:code] { "codes": [ { "code": "[Marin trackProductView:@\"product1\" withMetadata:nil]; \n", "language": "objectivec" } ] } [/block] And here is how to track an event with the extra data needed for a **conversion**. Conversions need to be setup in the app to read these events. [block:code] { "codes": [ { "code": "[Marin trackEvent:@\"Purchase\"\n withOrderId:@\"12345\"\n revenue:@\"19.99\"\nconversionMetadata:nil\n metadata:nil];", "language": "objectivec" } ] } [/block]