--- title: "Content Optimizer" slug: "expo-content-optimizer" description: "These methods are required to create variables for the App Content Optimizer based on data type." tags: ["react content optimizer"] updated: 2026-10-15T12:27:16Z published: 2026-10-15T12:27:16Z canonical: "academy.insiderone.com/expo-content-optimizer" --- > ## Documentation Index > Fetch the complete documentation index at: https://academy.insiderone.com/llms.txt > Use this file to discover all available pages before exploring further. # Content Optimizer > **Suggested readings**: [App Content Optimizer](https://academy.insiderone.com/docs/content-optimizer-overview), [Use Cases for App Content Optimizer](https://academy.insiderone.com/docs/content-optimizer-use-cases) The following methods are required to create variables for App Content Optimizer depending on the data type. ## Retrieving Content with Stored Data The Content Optimizer feature provides methods that store the last retrieved data on the device. When using these methods, the SDK retrieves and returns the most recently fetched value, reducing the need for repeated network requests. This approach enhances performance and ensures consistent content availability across sessions. If you prefer to prioritize efficiency and reliability, you can use these methods to maintain seamless content delivery without requiring a fresh data request each time. ### Get string data This method allows you to retrieve a string type of data. To add Content Optimizer variables, you must first [add your device as a test device](https://academy.insiderone.com/docs/adding-a-test-device-on-mobile-app). After adding it as a test device, you need to trigger the Content Optimizer method to display the respective variable in the Content Optimizer variables. | Parameter | Type | | --- | --- | | variableName | String | | defaultValue | String | | dataType | ContentOptimizerDataType | #### Method Signature ```javascript static getContentStringWithName(variableName: string, defaultValue: string, contentOptimizerDataType: number, callback: Function) ``` #### Method Example ```javascript RNInsider.getContentStringWithName("variableName", "defaultValue", ContentOptimizerDataType.Content, (contentString) => {    console.log("getContentStringWithName:", contentString); }); ``` --- ### Get boolean data This method allows you to retrieve a Boolean type of data. To add Content Optimizer variables, you must first [add your device as a test device](https://academy.insiderone.com/docs/adding-a-test-device-on-mobile-app). After adding it as a test device, you need to trigger the Content Optimizer method to display the respective variable in the Content Optimizer variables. | Parameter | Type | | --- | --- | | variableName | String | | defaultValue | Boolean | | dataType | ContentOptimizerDataType | #### Method Signature ```javascript static getContentBoolWithName(variableName: string, defaultValue: boolean, contentOptimizerDataType: number, callback: Function) ``` #### Method Example ```javascript RNInsider.getContentBoolWithName("variableName", true, ContentOptimizerDataType.Content, (contentBoolean) => {    console.log("getContentBoolWithName:", contentBoolean); }); ``` --- ### Get integer data This method allows you to retrieve integer-type data. To add Content Optimizer variables, you must first [add your device as a test device](https://academy.insiderone.com/docs/adding-a-test-device-on-mobile-app). After adding it as a test device, you need to trigger the Content Optimizer method to display the respective variable in the Content Optimizer variables. | Parameter | Type | | --- | --- | | variableName | String | | defaultValue | Integer | | dataType | ContentOptimizerDataType | #### Method Signature ```javascript static getContentIntWithName(variableName: string, defaultValue: number, contentOptimizerDataType: number, callback: Function) ``` #### Method Example ```javascript RNInsider.getContentIntWithName("variableName", 10, ContentOptimizerDataType.Content, (contentInt) => {    console.log("getContentIntWithName:", contentInt); }); ``` ## Retrieving Content Without Stored Data For use cases that require real-time content updates, alternative methods can be used that always fetch the latest data from the backend rather than using stored values. These methods ensure that the most up-to-date information is retrieved at the time of request, making them ideal for time-sensitive campaigns or dynamic content updates. By using this approach, you gain full control over content freshness, ensuring that the latest data is always reflected in your applications. If real-time data is unavailable at the time of the request, the specified default value will be returned, ensuring a smooth user experience. ### Get string data This method allows you to retrieve string-type data. To add Content Optimizer variables, you must first add your device as a test device. After adding it as a test device, you need to trigger the Content Optimizer method to display the respective variable in the Content Optimizer variables. | **Parameter** | **Type** | | --- | --- | | variableName | String | | defaultValue | String | | dataType | ContentOptimizerDataType | #### Method Signature ```javascript static getContentStringWithoutCache(variableName: string, defaultValue: string, contentOptimizerDataType: InsiderContentOptimizerDataType, callback: (content: string) => void): void; ``` #### Method Example ```javascript Insider.getContentStringWithoutCache('variable_name', 'defaultValue', InsiderContentOptimizerDataType.Element, value => console.log('[INSIDER [getContentStringWithoutCache]: ', value)); ``` ### Get boolean data This method allows you to retrieve a Boolean type of data. To add Content Optimizer variables, you must first [add your device as a test device](https://academy.insiderone.com/docs/adding-a-test-device-on-mobile-app). After adding it as a test device, you need to trigger the Content Optimizer method to display the respective variable in the Content Optimizer variables. | Parameter | Type | | --- | --- | | variableName | String | | defaultValue | Boolean | | dataType | ContentOptimizerDataType | #### Method Signature ```javascript static getContentBoolWithoutCache(variableName: string, defaultValue: boolean, contentOptimizerDataType: InsiderContentOptimizerDataType, callback: (content: boolean) => void): void; ``` #### Method Example ```javascript Insider.getContentBoolWithoutCache('variable_name', true, InsiderContentOptimizerDataType.Element, value => console.log('[INSIDER [getContentStringWithoutCache]: ', value)); ``` ### Get integer data This method allows you to retrieve integer-type data. To add Content Optimizer variables, you must first [add your device as a test device](https://academy.insiderone.com/docs/adding-a-test-device-on-mobile-app). After adding it as a test device, you need to trigger the Content Optimizer method to display the respective variable in the Content Optimizer variables. | Parameter | Type | | --- | --- | | variableName | String | | defaultValue | Integer | | dataType | ContentOptimizerDataType | #### Method Signature ```javascript static getContentIntWithoutCache(variableName: string, defaultValue: number, contentOptimizerDataType: InsiderContentOptimizerDataType, callback: (content: number) => void): void; ``` #### Method Example ```javascript Insider.getContentIntWithoutCache('variable_name', 10, InsiderContentOptimizerDataType.Element, value => console.log('[INSIDER [getContentStringWithoutCache]: ', value)); ``` ## markContentOptimizerAsSeen This method reports a seen impression for a Content Optimizer variable that the partner has just displayed. After fetching an optimized value with one of the getContent… methods and showing it to the user, the partner calls this method and the SDK fires a cont_opt_seen event carrying the campaign metadata. This lets Insider attribute impressions to the correct Content Optimizer campaign/variant. The event payload has the following: - variable_name: The name passed in (always present). - content_id: The campaign ID, when available. - variant_id: The variant ID, when available. > [!WARNING] > If the variableName is null, empty or not a string → no-op, and a parameter warning is logged. > > If the SDK is disabled or GDPR is opted out → no-op. > > If the variable was fetched via both the session-variables and the cache paths, session-variables wins. > > There is no deduplication. Each call fires a new event. E.g., 3 calls → 3 events. Call this method immediately after you have actually shown the optimized value to the user. Use the same variable name you passed to the getContent… method: 1. Fetch the value with a getContent… method. 2. Render it in the UI. 3. Call markContentOptimizerAsSeen with the same variable name. | Parameter | Data Type | | --- | --- | | variableName | String | ### Method signature ```typescript static markContentOptimizerAsSeen(variableName: string): void; ``` ### Method examples ```javascript RNInsider.markContentOptimizerAsSeen("variableName"); ``` ```javascript // 1. Fetch the optimized value RNInsider.getContentStringWithName(  "banner_title",  "Welcome!",  ContentOptimizerDataType.Element,  (bannerTitle) => {    // 2. Show it to the user    setTitle(bannerTitle);    // 3. Report the impression (fires `cont_opt_seen`)    RNInsider.markContentOptimizerAsSeen("banner_title");  } ); ``` ## Related - [Use Cases for App Content Optimizer](/content-optimizer-use-cases.md) - [App Content Optimizer](/app-content-optimizer.md)