---
title: Context Layer Implementation Guide
slug: sdks/context-layer-implementation-guide
docTags: 
createdAt: 2025-12-22T06:28:53.314Z
---

## Context Methods Reference

:::Heading{depth="3" indent="1"}
addAllCartData
:::

:::::Tabs
::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Signature&#x20;**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
public func addAllCartData(_ cartLines: [CartLine]?) throws
```
:::

:::Paragraph{indent="1"}
****
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets the complete cart information on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Use this method when you want to provide the **entire cart state** in a single operation.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
Refer to the [Cart Lines](https://developer.monetate.com/sdks/context-events-parameters#rHCwp) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
let cartLinesSample = [
            CartLine(sku: "SKU123", pid: "PID123", quantity: 1, currency: "USD", value: "19.99"),
            CartLine(sku: "SKU456", pid: "PID456", quantity: 2, currency: "USD", value: "39.98")
        ]
        do {
            try contextObj.addAllCartData(cartLinesSample)
         } catch {
            print(error.localizedDescription)
         }

```
:::
::::

::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature&#x20;**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addAllCartData(CartLine[] cartLines)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets the complete cart information on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Use this method when you want to provide the **entire cart state** in a single operation.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
Refer to the [Cart Lines](https://developer.monetate.com/sdks/context-events-parameters#rHCwp) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
CartLine cartLine1 = new CartLine();
cartLine1.setSku("SKU_1");
cartLine1.setPid("PID_1");
cartLine1.setQuantity(2);
cartLine1.setCurrency("US");
cartLine1.setValue("20");

CartLine cartLine2 = new CartLine();
cartLine2.setSku("SKU_2");
cartLine2.setPid("PID_2");
cartLine2.setQuantity(1);
cartLine2.setCurrency("US");
cartLine2.setValue("10");

Context context = new Context();
context.addAllCartData(new CartLine[] { cartLine1, cartLine2 });

```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature&#x20;**
:::

:::CodeblockTabs{indent="2"}
React Native

```java
addAllCartData(): {
  cartLines(products: cartLine[]): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets the complete cart information on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Use this method when you want to provide the **entire cart state** in a single operation.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
Refer to the [Cart Lines](https://developer.monetate.com/sdks/context-events-parameters#rHCwp) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
addAllCartData

```typescript
let context = new Context();

monetateContext.addSingleCartData().product({
            sku: "SKU-123",
            pid: "ddsds",
            productId: "123",
            quantity: 1,
            value: "1999",
            currency: "INR",
        });

```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature&#x20;**
:::

:::CodeblockTabs{indent="2"}
Web

```java
addAllCartData(): {
  cartLines(products: cartLine[]): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets the complete cart information on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Use this method when you want to provide the **entire cart state** in a single operation.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
Refer to the [Cart Lines](https://developer.monetate.com/sdks/context-events-parameters#rHCwp) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
addAllCartData

```typescript
let context = new Context();

monetateContext.addAllCartData().product({
            sku: "SKU-123",
            pid: "ddsds",
            productId: "123",
            quantity: 1,
            value: "1999",
            currency: "INR",
        });

```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addSingleCartData
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addSingleCartData(CartLine cartLine)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
&#x20;Sets a single cart item on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
&#x20;Use during **Add To Cart** operations.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
&#x20;Refer to the [Cart Lines](https://developer.monetate.com/sdks/context-events-parameters#rHCwp) parameters.

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
CartLine cartLine = new CartLine();
cartLine.setSku("SKU");
cartLine.setPid("PID");
cartLine.setQuantity(2);
cartLine.setCurrency("US");
cartLine.setValue("20");

Context context = new Context();
context.addSingleCartData(cartLine);
```
:::
::::

::::Tab{title="IOS"}
&#x20;        **Method Signature**

:::CodeblockTabs{indent="2"}
IOS

```swift
public func addSingleCartData(_ cartLine: CartLine?) throws
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
&#x20;Sets a single cart item on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
&#x20;Use during **Add To Cart** operations.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
&#x20;Refer to the [Cart Lines](https://developer.monetate.com/sdks/context-events-parameters#rHCwp) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
let cartLine = CartLine(sku: "sku6", pid: "pid4", quantity: 3, currency: "curr1", value: "21")
        do {
            try contextObj.addSingleCartData(cartLine)
        } catch {
            print(error.localizedDescription)
        }

```
:::

:::Paragraph{indent="1"}
***Notes***
:::

:::Paragraph{listStyleType="disc" indent="2"}
All required fields must be populated in the CartLine object
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React Native

```typescript
addSingleCartData(): {
  product(product: ProductLine): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
&#x20;Sets a single cart item on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
&#x20;Use during **Add To Cart** operations.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
&#x20;Refer to the [Cart Lines](https://developer.monetate.com/sdks/context-events-parameters#rHCwp) parameters.

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Example

```typescript
let context = new Context();

context
  .addSingleCartData()
  .product({
    sku: "sku-1",
    pid: "parent-1",
    productId: "prod-1",
    quantity: 1,
    value: "50",
    currency: "USD"
  });
```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Web

```java
addSingleCartData(): {
  product(product: ProductLine): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
&#x20;Sets a single cart item on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
&#x20;Use during **Add To Cart** operations.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
&#x20;Refer to the [Cart Lines](https://developer.monetate.com/sdks/context-events-parameters#rHCwp) parameters.

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Example

```typescript
let context = new Context();

context
  .addSingleCartData()
  .product({
    sku: "sku-1",
    pid: "parent-1",
    productId: "prod-1",
    quantity: 1,
    value: "50",
    currency: "USD"
  });
```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addCustomVariablesData
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature&#x20;**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addCustomVariablesData(CustomVariable[] customVariables)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets one or more custom variables for business-specific attributes.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
&#x20;Refer to the [Custom variables](https://developer.monetate.com/sdks/context-events-parameters#FyKGN) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
CustomVariable customVariable1 = new CustomVariable();
customVariable1.setVariable("Team A");
customVariable1.setValue("Winning Team");

CustomVariable customVariable2 = new CustomVariable();
customVariable2.setVariable("Team B");
customVariable2.setValue("Losing Team");

Context context = new Context();
context.addCustomVariablesData(
    new CustomVariable[] { customVariable1, customVariable2 }
);
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
 public func addCustomVariablesData(_ customVariables: [CustomVariablesModel]?) throws
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets one or more custom variables for business-specific attributes.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
&#x20;Refer to the [Custom variables](https://developer.monetate.com/sdks/context-events-parameters#FyKGN) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
let customVariablesModels = [
            CustomVariablesModel(variable: "userType", value: "premium"),
            CustomVariablesModel(variable: "loyaltyLevel", value: 3)
        ]
        
try? contextObj.addCustomVariablesData(customVariablesModels)

```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```swift
addCustomVariablesData(): {
  variable(variable: string): this;
  value(value: any): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets one or more custom variables for business-specific attributes.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
&#x20;Refer to the [Custom variables](https://developer.monetate.com/sdks/context-events-parameters#FyKGN) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
let context = Context()
context
  .addCustomVariablesData()
  .variable("userType")
  .value("premium")
  .variable("cartValue")
  .value(1500)

```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Web

```swift
addCustomVariablesData(): {
  variable(variable: string): this;
  value(value: any): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets one or more custom variables for business-specific attributes.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
&#x20;Refer to the [Custom variables](https://developer.monetate.com/sdks/context-events-parameters#FyKGN) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
let context = Context()
context
  .addCustomVariablesData()
  .variable("userType")
  .value("premium")
  .variable("cartValue")
  .value(1500)

```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addIpAddress
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addIpAddress(String ipAddress)public func addIpAddress(_ ipAddress: String?) throws

```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets the IP address on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [IPAddress ](https://developer.monetate.com/sdks/context-events-parameters#XbdiP)parameters.
:::

:::Paragraph{indent="1"}

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
Context context = new Context();
context.addIpAddress("1.0.0.0");
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
public func addIpAddress(_ ipAddress: String?) throws
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets the IP address on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [IPAddress ](https://developer.monetate.com/sdks/context-events-parameters#XbdiP)parameters.
:::

:::Paragraph{indent="1"}

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
try? contextObj.addIpAddress("192.168.1.1")
```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addIpAddress(): {
  ipAddress(ipAddress: string): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets the IP address on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [IPAddress ](https://developer.monetate.com/sdks/context-events-parameters#XbdiP)parameters.
:::

:::Paragraph{indent="1"}

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
const  context = new Context();
context.addIpAddress("1.0.0.0");
```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
addIpAddress(): {
  ipAddress(ipAddress: string): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets the IP address on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [IPAddress ](https://developer.monetate.com/sdks/context-events-parameters#XbdiP)parameters.
:::

:::Paragraph{indent="1"}

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
const  context = new Context();
context.addIpAddress("1.0.0.0");
```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addMetaData
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addMetaData(Language language)
```
:::

:::Paragraph{indent="1"}
**Description:-&#x20;**
:::

:::Paragraph{listStyleType="disc" indent="3"}
Sets metadata on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="3"}
Currently used for language context.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="3"}
Refer to the [Meta Data event ](https://developer.monetate.com/sdks/context-events-parameters#4Soea)parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
Language language = new Language();
language.setLanguage("EN");

Context context = new Context();
context.addMetaData(language);
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
 public func addMetaData(language: Language?) throws
```
:::

:::Paragraph{indent="1"}
**Description:-&#x20;**
:::

:::Paragraph{listStyleType="disc" indent="3"}
Sets metadata on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="3"}
Currently used for language context.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="3"}
Refer to the [Meta Data event ](https://developer.monetate.com/sdks/context-events-parameters#4Soea)parameters.
:::

:::Paragraph{indent="1"}
****
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
let language = Language(language: "en-US")

try? contextObj.addMetaData(language: language)
```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addMetaData(): {
  language(language: string): void;
}
```
:::

:::Paragraph{indent="1"}
**Description:-&#x20;**
:::

:::Paragraph{listStyleType="disc" indent="3"}
Sets metadata on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="3"}
Currently used for language context.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="3"}
Refer to the [Meta Data event ](https://developer.monetate.com/sdks/context-events-parameters#4Soea)parameters.
:::

:::Paragraph{indent="1"}
****
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
let language = Language(language: "en-US")

try? contextObj.addMetaData(language: language)
```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
 public func addMetaData(language: Language?) throws
```
:::

:::Paragraph{indent="1"}
**Description:-&#x20;**
:::

:::Paragraph{listStyleType="disc" indent="3"}
Sets metadata on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="3"}
Currently used for language context.
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="3"}
Refer to the [Meta Data event ](https://developer.monetate.com/sdks/context-events-parameters#4Soea)parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
let contextObj = ContextObj()
let language = Language(language: "en-US")

try? contextObj.addMetaData(language: language)
```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addPageDetails
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature :-&#x20;**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addPageDetails(
    String pageType,
    String url,
    String[] categories,
    String[] breadcrumbs,
    String path
)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets page-level details including `pageType`, `URL/path`, `categories`, and `breadcrumbs`.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Page Detail View event](https://developer.monetate.com/sdks/context-events-parameters#IE5eB) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
Context context = new Context();
context.addPageDetails(
    "home-page",
    "https://example.com",
    new String[] { "category1", "category2" },
    new String[] { "breadcrumb1", "breadcrumb2" },
    "abc/xyz/pqr/testpath"
);
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature :-&#x20;**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
public func addPageDetails(pageType: String, path: String?, url: String?, categories: [String]?, breadcrumbs: [String]?) throws 
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets page-level details including `pageType`, `URL/path`, `categories`, and `breadcrumbs`.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Page Detail View event](https://developer.monetate.com/sdks/context-events-parameters#IE5eB) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
try? contextObj.addPageDetails(pageType: "home",
 path: "path", 
 url: nil, 
 categories: ["electronics", "sale"], 
 breadcrumbs: ["home", "deals"]
 )
```
:::

:::Paragraph{indent="1"}
**Notes**
:::

:::Paragraph{listStyleType="disc" indent="2"}
`pageType` is mandatory&#x20;
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Either `url` or `path` is required
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature :-&#x20;**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addPageDetails(): {
  url(url: string): this;
  path(path: string): this;
  pageType(pageType: string): this;
  breadcrumbs(breadcrumbs: string[]): this;
  categories(categories: string[]): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets page-level details including `pageType`, `URL/path`, `categories`, and `breadcrumbs`.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Page Detail View event](https://developer.monetate.com/sdks/context-events-parameters#IE5eB) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
React Native

```typescript
Context context = new Context();
context
  .addPageDetails()
  .url(window.location.href)
  .path(window.location.pathname)
  .pageType("home")
  .breadcrumbs(["Home"])
  .categories(["Homepage"]);

```
:::

:::Paragraph{indent="1"}
****

:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature :-&#x20;**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
addPageDetails(): {
  url(url: string): this;
  path(path: string): this;
  pageType(pageType: string): this;
  breadcrumbs(breadcrumbs: string[]): this;
  categories(categories: string[]): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets page-level details including `pageType`, `URL/path`, `categories`, and `breadcrumbs`.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Page Detail View event](https://developer.monetate.com/sdks/context-events-parameters#IE5eB) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
Context context = new Context();
context
  .addPageDetails()
  .url(window.location.href)
  .path(window.location.pathname)
  .pageType("home")
  .breadcrumbs(["Home"])
  .categories(["Homepage"]);

```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addPageEventsData
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addPageEventsData(String[] pageEventsData)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets page event identifiers on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Page Events](https://developer.monetate.com/sdks/context-events-parameters#4R_yd) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
Context context = new Context();
context.addPageEventsData(new String[] { "eventData1", "eventData2" });
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
public func addPageEventsData(_ pageEventsData: [String]?) throws
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets page event identifiers on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Page Events](https://developer.monetate.com/sdks/context-events-parameters#4R_yd) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
try? contextObj.addPageEventsData(["pageLoad", 
"buttonClick", 
"formSubmit"])
```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addPageEventsData(): {
  pageEvents(events: string[]): this ;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets page event identifiers on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Page Events](https://developer.monetate.com/sdks/context-events-parameters#4R_yd) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
Context context = new Context();
context
  .addPageEventsData()
  .pageEvents(["click", "banner", "homepage"]);

```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addPageEventsData(): {
  pageEvents(events: string[]): this ;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets page event identifiers on the Context object.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Page Events](https://developer.monetate.com/sdks/context-events-parameters#4R_yd) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
Context context = new Context();
context
  .addPageEventsData()
  .pageEvents(["click", "banner", "homepage"]);

```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addProductDetails
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addProductDetails(Product[] productsData)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets product-level details such as `productID` and `SKU`.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Product Detail View Event](https://developer.monetate.com/sdks/context-events-parameters#r1pba) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
Product product1 = new Product();
product1.setProductId("PID1");
product1.setSku("SKU1");

Product product2 = new Product();
product2.setProductId("PID2");
product2.setSku("SKU2");

Context context = new Context();
context.addProductDetails(new Product[] { product1, product2 });
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
public func addProductDetails(_ productsData: [Product]?) throws
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets product-level details such as `productID` and `SKU`.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Product Detail View Event](https://developer.monetate.com/sdks/context-events-parameters#r1pba) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
 let productsSample = [
            Product(productId: "PROD001", sku: "SKU001"),
            Product(productId: "PROD002", sku: "SKU002")
        ]
let contextObj = ContextObj()
try? contextObj.addProductDetails(productsSample)
```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addProductDetails(): {
  product(product: { sku: string; productId?: string }): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets product-level details such as `productID` and `SKU`.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Product Detail View Event](https://developer.monetate.com/sdks/context-events-parameters#r1pba) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
 const context = new Context();

context
  .addProductDetails()
  .productId("123")
  .productSKU("SKU-1");
```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
****
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addProductDetails(): {
  product(product: { sku: string; productId?: string }): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets product-level details such as `productID` and `SKU`.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Product Detail View Event](https://developer.monetate.com/sdks/context-events-parameters#r1pba) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
 const context = new Context();

context
  .addProductDetails()
  .productId("123")
  .productSKU("SKU-1");
```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addProductThumbnailsData
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addProductThumbnailsData(String[] products)
```

IOS

```swift
public func addProductThumbnailsData(_ products: [String]?) throws
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets product thumbnail view data.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Product Thumbnails Event](https://developer.monetate.com/sdks/context-events-parameters#SiIRq) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
Context context = new Context();
context.addProductThumbnailsData(new String[] { "product21", "product43" });
```

IOS

```swift
let contextObj = ContextObj()
try? contextObj.addProductThumbnailsData(["PROD001", "PROD002", "PROD003"])
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
public func addProductThumbnailsData(_ products: [String]?) throws
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets product thumbnail view data.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Product Thumbnails Event](https://developer.monetate.com/sdks/context-events-parameters#SiIRq) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
try? contextObj.addProductThumbnailsData(["PROD001", "PROD002", "PROD003"])
```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addProductThumbnailsData(): {
  product(product: string[]): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets product thumbnail view data.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Product Thumbnails Event](https://developer.monetate.com/sdks/context-events-parameters#SiIRq) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
context
  .addProductThumbnailsData()
  .product(["SKU-1", "SKU-2", "SKU-3"]);
```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
addProductThumbnailsData(): {
  product(product: string[]): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets product thumbnail view data.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Product Thumbnails Event](https://developer.monetate.com/sdks/context-events-parameters#SiIRq) parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
context
  .addProductThumbnailsData()
  .product(["SKU-1", "SKU-2", "SKU-3"]);
```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addPurchaseData
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addPurchaseData(String purchaseId, PurchaseLine[] purchaseLineData)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets purchase transaction data along with purchased line items.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Purchase Event](https://developer.monetate.com/sdks/context-events-parameters#f37yX)  and **[Purachse Lines](https://developer.monetate.com/sdks/context-events-parameters#5PKlQ)** parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
PurchaseLine purchaseLine = new PurchaseLine();
purchaseLine.setSku("SKU1");
purchaseLine.setPid("PID1");
purchaseLine.setQuantity(2);
purchaseLine.setCurrency("US");
purchaseLine.setValue("23.00");

Context context = new Context();
context.addPurchaseData("1b2c3d", new PurchaseLine[] { purchaseLine });

```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
public func addPurchaseData(purchaseId: String?, purchaseLineData: [PurchaseLine]?) throws
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets purchase transaction data along with purchased line items.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Purchase Event](https://developer.monetate.com/sdks/context-events-parameters#f37yX)  and **[Purachse Lines](https://developer.monetate.com/sdks/context-events-parameters#5PKlQ)** parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let purchaseLinesSample: [PurchaseLine] = [
            PurchaseLine(sku: "sku0", pid: "PID123", quantity: 1, currency: "USD", value: "19.99"),
            PurchaseLine(sku: "sku1", pid: "PID456", quantity: 2, currency: "USD", value: "39.98")
        ]
let contextObj = ContextObj()
try? contextObj.addPurchaseData(purchaseId: "purchase123", purchaseLineData: purchaseLinesSample)

```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addPurchaseData(): {
  purchaseId(purchaseId: string): this;
  purchaseLines(products: ProductLine[]): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets purchase transaction data along with purchased line items.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Purchase Event](https://developer.monetate.com/sdks/context-events-parameters#f37yX)  and **[Purachse Lines](https://developer.monetate.com/sdks/context-events-parameters#5PKlQ)** parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
const context = new Context();

context
  .addPurchaseData()
  .purchaseId("ORDER-123")
  .purchaseLines([
    {
      sku: "SKU-1",
      pid: "P1",
      productId: "123",
      quantity: 2,
      value: "100",
      currency: "USD"
    }
  ]);
```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
addPurchaseData(): {
  purchaseId(purchaseId: string): this;
  purchaseLines(products: ProductLine[]): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets purchase transaction data along with purchased line items.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Purchase Event](https://developer.monetate.com/sdks/context-events-parameters#f37yX)  and **[Purachse Lines](https://developer.monetate.com/sdks/context-events-parameters#5PKlQ)** parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
const context = new Context();

context
  .addPurchaseData()
  .purchaseId("ORDER-123")
  .purchaseLines([
    {
      sku: "SKU-1",
      pid: "P1",
      productId: "123",
      quantity: 2,
      value: "100",
      currency: "USD"
    }
  ]);
```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addScreenSizeData
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addScreenSizeData(Integer screenHeight, Integer screenWidth)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets screen size information.

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
Context context = new Context();
context.addScreenSizeData(211, 2313);
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
public func addScreenSizeData(screenHeight: Int?, screenWidth: Int?)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets screen size information.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [ScreenSize Event ](https://app.archbee.com/docs/gI3o1i4XdDy584dqSyxqi/N3hSu6YazAW65BLJFETrG#0AeHt)parameters.

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
try? contextObj.addScreenSizeData(screenHeight: 1000, screenWidth: 400)
```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addScreenSizeData(): {
  width(width: number): this;
  height(height: number): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets screen size information.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [ScreenSize Event ](https://app.archbee.com/docs/gI3o1i4XdDy584dqSyxqi/N3hSu6YazAW65BLJFETrG#0AeHt)parameters.

:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
context
  .addScreenSizeData()
  .width(211)
  .height(400);
```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
addScreenSizeData(): {
  width(width: number): this;
  height(height: number): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets screen size information.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [ScreenSize Event ](https://app.archbee.com/docs/gI3o1i4XdDy584dqSyxqi/N3hSu6YazAW65BLJFETrG#0AeHt)parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
context
  .addScreenSizeData()
  .width(211)
  .height(400);
```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addCoordinatesData
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addCoordinatesData(String latitude, String longitude)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets coordinate (latitude, longitude) data.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [Coordinate Event ](https://app.archbee.com/docs/gI3o1i4XdDy584dqSyxqi/N3hSu6YazAW65BLJFETrG#eMWlU)parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
Context context = new Context();
context.addCoordinatesData("19.0760", "72.8777");
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
 public func addCoordinatesData(latitude: String?, longitude: String?)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets coordinate (latitude, longitude) data.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
IOS

```swift
let contextObj = ContextObj()
try? contextObj.addCoordinatesData(latitude: "37.7749", longitude: "-122.4194")
```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addCoordinatesData(): {
  latitude(latitude: string): this;
  longitude(longitude: string): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets coordinate (**latitude**, **longitude**) data.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
Context context = new Context();

context
  .addCoordinatesData()
  .latitude("12.9716")
  .longitude("77.5946");

```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
addCoordinatesData(): {
  latitude(latitude: string): this;
  longitude(longitude: string): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets coordinate (**latitude**, **longitude**) data.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
Context context = new Context();

context
  .addCoordinatesData()
  .latitude("12.9716")
  .longitude("77.5946");

```
:::
::::
:::::

:::Heading{depth="3" indent="1"}
addUserAgentData
:::

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addUserAgentData(String data)
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets user agent / device information.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [UserAgent Event ](https://app.archbee.com/docs/gI3o1i4XdDy584dqSyxqi/N3hSu6YazAW65BLJFETrG#6o-rN)parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
DeviceDetails details = new DeviceDetails();
details.setDevice("device-name-here");
details.setModel("device-model-here");
details.setOsApiLevel("OS-API-level-here");
details.setOsVersion("OS-version-here");
details.setProductName("product-name-here");

String deviceDetails = personalization.refactorDeviceDetails(details);

Context context = new Context();
context.addUserAgentData(deviceDetails);

```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Android

```java
public void addUserAgentData(String data)
```

IOS

```swift
public func addUserAgentData(_ data: String?) throws
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets user agent / device information.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Android

```java
DeviceDetails details = new DeviceDetails();
details.setDevice("device-name-here");
details.setModel("device-model-here");
details.setOsApiLevel("OS-API-level-here");
details.setOsVersion("OS-version-here");
details.setProductName("product-name-here");

// String deviceDetails = personalization.refactorDeviceDetails(details);
String deviceDetails = personalization.refactorDeviceDetails(null);

Context context = new Context();
context.addUserAgentData(deviceDetails);

```

IOS

```swift
  try? contextObj.addUserAgentData("Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1")
```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
addUserAgentData(): {
  userAgent(userAgent: string): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets user agent / device information.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [UserAgent Event ](https://app.archbee.com/docs/gI3o1i4XdDy584dqSyxqi/N3hSu6YazAW65BLJFETrG#6o-rN)parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**

:::

:::CodeblockTabs{indent="2"}
React-Native

```typescript
Context context = new Context();
context
  .addUserAgentData()
  .userAgent("user-Agent");
```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
**Method Signature**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
addUserAgentData(): {
  userAgent(userAgent: string): this;
}
```
:::

:::Paragraph{indent="1"}
**Description**
:::

:::Paragraph{listStyleType="disc" indent="2"}
Sets user agent / device information.
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Refer to the [UserAgent Event ](https://app.archbee.com/docs/gI3o1i4XdDy584dqSyxqi/N3hSu6YazAW65BLJFETrG#6o-rN)parameters.
:::

:::Paragraph{indent="1"}
**Usage Example**
:::

:::CodeblockTabs{indent="2"}
Web

```typescript
Context context = new Context();
context
  .addUserAgentData()
  .userAgent(navigator.userAgent);  
```
:::

:::Paragraph{indent="1"}
****
:::
::::
:::::

***

## <u>Validation & Error Handling</u>

:::::Tabs
::::Tab{title="Android"}
:::Paragraph{indent="1"}
All Context methods validate required inputs before setting data.
:::

:::Paragraph{indent="2"}
If any required field is:
:::

:::Paragraph{listStyleType="disc" indent="3"}
Missing&#x20;
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="3"}
Null&#x20;
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="3"}
Empty&#x20;
:::

:::Paragraph{indent="1"}
the SDK throws an IllegalArgumentException.
:::

:::CodeblockTabs{indent="1"}
Android

```java
try {
    context.addIpAddress("1.0.0.0");
} catch (IllegalArgumentException e) {
    // Handle validation error
}
```
:::
::::

::::Tab{title="IOS"}
:::Paragraph{indent="1"}
All Context methods validate required inputs before setting data.
:::

:::Paragraph{indent="1"}
If any required field is:
:::

:::Paragraph{listStyleType="disc" indent="2"}
Missing&#x20;
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Null&#x20;
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
Empty&#x20;
:::

:::Paragraph{indent="1"}
the SDK throws an IllegalArgumentException.
:::

:::CodeblockTabs{indent="1"}
IOS

```swift
do {
      try contextObj.addIpAddress("1.0.0.0")
} catch {
      // Handle validation error
}
```
:::
::::

::::Tab{title="React-Native"}
:::Paragraph{indent="1"}
All Context methods validate required inputs before setting data.
:::

:::Paragraph{indent="1"}
If any required field is:
:::

:::Paragraph{listStyleType="disc" indent="2"}
Missing&#x20;
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Null&#x20;
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
Empty&#x20;
:::

:::Paragraph{indent="1"}
the SDK throws an IllegalArgumentException.

:::

:::CodeblockTabs{indent="1"}
React-Native

```typescript
try {
    context.addIpAddress("1.0.0.0");
} catch (err) {
    // Handle validation error
}
```
:::
::::

::::Tab{title="Web"}
:::Paragraph{indent="1"}
All Context methods validate required inputs before setting data.
:::

:::Paragraph{indent="1"}
If any required field is:
:::

:::Paragraph{listStyleType="disc" indent="2"}
Missing&#x20;
:::

:::Paragraph{listStyleType="disc" listStart="2" indent="2"}
Null&#x20;
:::

:::Paragraph{listStyleType="disc" listStart="3" indent="2"}
Empty&#x20;
:::

:::Paragraph{indent="1"}
the SDK throws an IllegalArgumentException.

:::

:::CodeblockTabs{indent="1"}
Web

```typescript
try {
    context.addIpAddress("1.0.0.0");
} catch (err) {
    // Handle validation error
}
```
:::
::::
:::::

***

## Context Layer for Event Data Reporting

:::Paragraph{indent="1"}
The Context Layer allows you to pass event-specific data to the SDK’s [reporting methods. ](https://developer.monetate.com/sdks/methods#59AlM)
:::

:::Heading{depth="3" indent="2"}
Reporting  Cart data
:::

:::Paragraph{indent="2"}
**example :-&#x20;**
:::

:::CodeblockTabs{indent="3"}
Android

```java
// seeting up user details
User user = new User();
user.setDeviceId("my-deviceid");

//setting up account details
Account account = new Account("monetate.mybigcommerce.com", "a-3e41bf76", "p", "monetatebc");

//creating Personalization instance
Personalization personalization = new Personalization(user, account);

//settingcartline data
CartLine cartLine1 = new CartLine();
cartLine1.setSku("SKU1");
cartLine1.setPid("PID1");
cartLine1.setQuantity(2);
cartLine1.setCurrency("US");
cartLine1.setValue("20");

CartLine cartLine2 = new CartLine();
cartLine2.setSku("SKU2");
cartLine2.setPid("PID2");
cartLine2.setQuantity(1);
cartLine2.setCurrency("US");
cartLine2.setValue("10");

//setting data to context
Context context = new Context();
context.addAllCartData(new CartLine[] { cartLine1, cartLine2 });

//reporting entire CartData
personalization.reportCartData(context);
```

IOS

```swift
let cartLinesSample = [
            CartLine(sku: "SKU123", pid: "PID123", quantity: 1, currency: "USD", value: "19.99"),
            CartLine(sku: "SKU456", pid: "PID456", quantity: 2, currency: "USD", value: "39.98")
        ]

let contextObj = ContextObj()
try? contextObj.addAllCartData(cartLinesSample)

personalization.reportCartData(contextData: contextObj)
```

React-Native

```typescript
const account = {
    account: "monetate",
    domain: "monetate",
    name: "a-123445,
    instance: "p",
    shortname: "monetate",
    engineHostName:"host-name"
};

const user = {
    deviceId: "",
    monetateId: Personalization.generateMonetateId(),
    customerId: "customerId",
};

const personalization = new Personalization(user, account);

let context = new Context();

monetateContext.addAllCartData().product({
            sku: "SKU-123",
            pid: "ddsds",
            productId: "123",
            quantity: 1,
            value: "1999",
            currency: "INR",
        });
        
//reporting entire CartData
personalization.reportCartData();
```

Web

```typescript
const account = {
    account: "monetate",
    domain: "monetate",
    name: "a-123445",
    instance: "p",
    shortname: "monetate",
    engineHostName:"host-name"
};
const user = {
    deviceId: "",
    monetateId: Personalization.generateMonetateId(),
    customerId: "customerId",
};

const personalization = new Personalization(user, account);

let context = new Context();

monetateContext.addAllCartData().product({
            sku: "SKU-123",
            pid: "ddsds",
            productId: "123",
            quantity: 1,
            value: "1999",
            currency: "INR",
        });
        
//reporting entire CartData
personalization.reportCartData();
```
:::

***

## Using Context with getActions()

:::Paragraph{indent="1"}
The **[getActions](https://developer.monetate.com/sdks/methods#DJr_q)** method retrieves experience-based actions from the personalization engine.&#x20;
:::

:::Paragraph{indent="1"}
The Context Layer provides all input signals required by the experience rules (IP, page details, product details, etc.).
In **Single-Context evaluation** only single data is required to satisfy the experience&#x20;
In **Multi-Context evaluation&#x20;**&#x6D;ultiple data is required to satisy the experience
:::

:::Heading{depth="3" indent="1"}
Example 1: Single-Context Evaluation
:::

:::CodeblockTabs{indent="2"}
Android

```java
// seeting up user details
User user = new User();
user.setDeviceId("my-deviceid");

//setting up account details
Account account = new Account("monetate.mybigcommerce.com", "a-3e41bf76", "p", "monetatebc");

//creating Personalization instance
Personalization personalization = new Personalization(user, account);

//setting data to context
Context context = new Context();
context.addIpAddress("1.0.0.0");

//calling getactions
personalization.getActions(
    context,
    new String[] { "monetate:action:OmnichannelJson" },
    false,
    new ActionsCallback() {
        @Override
        public void onSuccess(String actions) {
            System.out.println("Actions Data: " + actions);
        }

        @Override
        public void onError(Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
);
```

IOS

```swift
let contextObj = ContextObj()
try? contextObj.addIpAddress("1.0.0.0")

objPersonalization.getActions(context: contextObj,  
                              arrActionTypes: ["monetate:action:OmnichannelJson"],
                              includeReporting: false)
                .on(success: { (actions) in
                        self.handleAction(actions: actions)
                }) { err in
                        print(err.localizedDescription)
                }

```

React-Native

```typescript
const account = {
    account: "monetate",
    domain: "monetate",
    name: "a-123445,
    instance: "p",
    shortname: "monetate",
    engineHostName:"host-name"
};
const user = {
    deviceId: "",
    monetateId: Personalization.generateMonetateId(),
    customerId: "customerId",
};

const personalization = new Personalization(user, account);

//setting data to context
const monetateContext = new Context();
context.addIpAddress("1.0.0.0");

 coreSdkInstance.getActions(
 ["monetate:action:OmnichannelJson"] , monetateContext)
 .then((res: any) => console.log("Action ", res));
```

Web

```typescript
const account = {
    account: "monetate",
    domain: "monetate",
    name: "a-123445,
    instance: "p",
    shortname: "monetate",
    engineHostName:"host-name"
};
const user = {
    deviceId: "",
    monetateId: Personalization.generateMonetateId(),
    customerId: "customerId",
};

const personalization = new Personalization(user, account);

//setting data to context
const monetateContext = new Context();
context.addIpAddress("1.0.0.0");

 coreSdkInstance.getActions(
 [], monetateContext)
 .then((res: any) => console.log("Action ", res));
```
:::

:::Heading{depth="3" indent="1"}
Example 2: Multi-Context Evaluation

:::

:::CodeblockTabs{indent="2"}
Android

```java
Context context = new Context();

// setting multipole data to context
context.addIpAddress("1.0.0.0");
context.addPageDetails(
    "home-page",
    "https://example.com",
    new String[] { "category1" },
    new String[] { "breadcrumb1" },
    "abc/xyz"
);

// calling getActions
personalization.getActions(
    context,
    new String[] { "monetate:action:OmnichannelJson" },
    false,
    new ActionsCallback() {

        @Override
        public void onSuccess(String actions) {
            System.out.println("Actions Data: " + actions);
        }

        @Override
        public void onError(Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
);
```

IOS

```swift
let contextObj = ContextObj()

try? contextObj.addIpAddress("1.0.0.0")

try? contextObj.addPageDetails(pageType: "home", 
                          path: "deals/offers", 
                          url: nil, 
                          categories: ["electronics", "sale"], 
                          breadcrumbs: ["home", "deals"])

objPersonalization.getActions(context: contextObj,  
                              arrActionTypes: ["monetate:action:OmnichannelJson"],
                              includeReporting: false)
                .on(success: { (actions) in
                        self.handleAction(actions: actions)
                }) { err in
                        print(err.localizedDescription)
                }

```

React-Native

```typescript
const account = {
    account: "monetate",
    domain: "monetate",
    name: "a-123445,
    instance: "p",
    shortname: "monetate",
    engineHostName:"host-name"
};
const user = {
    deviceId: "",
    monetateId: Personalization.generateMonetateId(),
    customerId: "customerId",
};

const personalization = new Personalization(user, account);

//setting data to context
const monetateContext = new Context();
context.addIpAddress("1.0.0.0");

monetateContext.addAllCartData().product({
            sku: "SKU-123",
            pid: "ddsds",
            productId: "123",
            quantity: 1,
            value: "1999",
            currency: "INR",
        });
        
 coreSdkInstance.getActions(
 ["monetate:action:OmnichannelJson" ], monetateContext)
 .then((res: any) => console.log("Action ", res));
```

Web

```typescript
const account = {
    account: "monetate",
    domain: "monetate",
    name: "a-123445,
    instance: "p",
    shortname: "monetate",
    engineHostName:"host-name"
};
const user = {
    deviceId: "",
    monetateId: Personalization.generateMonetateId(),
    customerId: "customerId",
};

const personalization = new Personalization(user, account);

//setting data to context
const monetateContext = new Context();
context.addIpAddress("1.0.0.0");

monetateContext.addAllCartData().product({
            sku: "SKU-123",
            pid: "ddsds",
            productId: "123",
            quantity: 1,
            value: "1999",
            currency: "INR",
        });
        
 coreSdkInstance.getActions(
 ["monetate:action:OmnichannelJson" ], monetateContext)
 .then((res: any) => console.log("Action ", res));
```
:::

:::Paragraph{indent="2"}
The SDK evaluates all data present inside the Context object and returns the appropriate actions.
:::

