Expand my Community achievements bar.

SOLVED

Products variable implementation in AEP mobile SDK

Avatar

Level 2

Hi,

 

I am trying to implement products Variable/Event using AEP mobile SDK. Could anyone Please suggest possible implementation ways?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Sure, I can help you with that. Here are some possible implementation ways for products Variable/Event using AEP mobile SDK for Adobe Analytics:

  • Using the ProductVariable class: The ProductVariable class allows you to track product-related data, such as the product name, price, and quantity. You can use this class to track product views, product clicks, and product purchases.

To implement this, you would need to create a new ProductVariable object and set the product name, price, and quantity. You would then need to call the track() method to track the product variable.

// Create a new ProductVariable object
ProductVariable productVariable = new ProductVariable();

// Set the product name
productVariable.setName("Product Name");

// Set the product price
productVariable.setPrice(100);

// Set the product quantity
productVariable.setQuantity(1);

// Track the product variable
productVariable.track();
  • Using the ProductEvent class: The ProductEvent class allows you to track product-related events, such as a product being added to the cart or a product being purchased. You can use this class to track product engagement events, such as a product being viewed or a product being clicked.

To implement this, you would need to create a new ProductEvent object and set the product name, event type, and event properties. You would then need to call the track() method to track the product event.

// Create a new ProductEvent object
ProductEvent productEvent = new ProductEvent();

// Set the product name
productEvent.setName("Product Name");

// Set the event type
productEvent.setEventType("Product Added to Cart");

// Set the event properties
productEvent.setProperty("Quantity", 1);

// Track the product event
productEvent.track();
  • Using the ProductDataLayer class: The ProductDataLayer class allows you to track product-related data and events using the Google Tag Manager (GTM) Data Layer. This class provides a way to track product data and events without having to modify your app code.

To implement this, you would need to create a new ProductDataLayer object and set the product data and events. You would then need to call the push() method to push the product data and events to the GTM Data Layer.

// Create a new ProductDataLayer object
ProductDataLayer productDataLayer = new ProductDataLayer();

// Set the product data
productDataLayer.setProductName("Product Name");
productDataLayer.setProductPrice(100);
productDataLayer.setProductQuantity(1);

// Set the product events
productDataLayer.setProductEventType("Product Added to Cart");
productDataLayer.setProperty("Quantity", 1);

// Push the product data and events to the GTM Data Layer
productDataLayer.push();

I hope this helps! Let me know if you have any other questions.

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Sure, I can help you with that. Here are some possible implementation ways for products Variable/Event using AEP mobile SDK for Adobe Analytics:

  • Using the ProductVariable class: The ProductVariable class allows you to track product-related data, such as the product name, price, and quantity. You can use this class to track product views, product clicks, and product purchases.

To implement this, you would need to create a new ProductVariable object and set the product name, price, and quantity. You would then need to call the track() method to track the product variable.

// Create a new ProductVariable object
ProductVariable productVariable = new ProductVariable();

// Set the product name
productVariable.setName("Product Name");

// Set the product price
productVariable.setPrice(100);

// Set the product quantity
productVariable.setQuantity(1);

// Track the product variable
productVariable.track();
  • Using the ProductEvent class: The ProductEvent class allows you to track product-related events, such as a product being added to the cart or a product being purchased. You can use this class to track product engagement events, such as a product being viewed or a product being clicked.

To implement this, you would need to create a new ProductEvent object and set the product name, event type, and event properties. You would then need to call the track() method to track the product event.

// Create a new ProductEvent object
ProductEvent productEvent = new ProductEvent();

// Set the product name
productEvent.setName("Product Name");

// Set the event type
productEvent.setEventType("Product Added to Cart");

// Set the event properties
productEvent.setProperty("Quantity", 1);

// Track the product event
productEvent.track();
  • Using the ProductDataLayer class: The ProductDataLayer class allows you to track product-related data and events using the Google Tag Manager (GTM) Data Layer. This class provides a way to track product data and events without having to modify your app code.

To implement this, you would need to create a new ProductDataLayer object and set the product data and events. You would then need to call the push() method to push the product data and events to the GTM Data Layer.

// Create a new ProductDataLayer object
ProductDataLayer productDataLayer = new ProductDataLayer();

// Set the product data
productDataLayer.setProductName("Product Name");
productDataLayer.setProductPrice(100);
productDataLayer.setProductQuantity(1);

// Set the product events
productDataLayer.setProductEventType("Product Added to Cart");
productDataLayer.setProperty("Quantity", 1);

// Push the product data and events to the GTM Data Layer
productDataLayer.push();

I hope this helps! Let me know if you have any other questions.

Avatar

Community Advisor

Unfortunately, this one has to be fully done by your developers.

 

Products is not available in Processing Rules... so similar to how pageName and actionName have to be passed in tracking calls from the trackState and trackAction functions as &&pageName and &&actionName

 

products and the corresponding events have to be added into the Additional Context Data (not as "context" but as &&products, etc)

 

So for example (standard context variable implementation):

Map<String, String> additionalContextData = new HashMap<String, String>();         
additionalContextData.put("content.Item1", "value");
additionalContextData.put("content.Item2", "another value");         
MobileCore.trackState("homePage", additionalContextData);

 

 

Now, if you need product data, and events:

Map<String, String> additionalContextData = new HashMap<String, String>();         
additionalContextData.put("content.Item1", "value");
additionalContextData.put("content.Item2", "another value");
additionalContextData.put("&&products", "category;prod-1;1;9.99;event1=1|event2=1;eVar1=something|eVar2=something else,category;prod-2;1;5.35;event1=1|event3=1;eVar1=some value|eVar2=other value");
additionalContextData.put("&&events", "event1,event2,event3,purchase");
MobileCore.trackState("purchase success thank you", additionalContextData);

 

 

In our implementation, I only have the developers populate the events specifically tied to products (since I cannot check which events are part of products (such as the merchandising events, and maybe purchase event.. unless purchase is part of a specific trackAction that I can add myself... i.e. ActionName equals "successful purchase")

 

You can continue to use any of your processing rules event mappings in conjunction with this solution. This keeps 90% of the implementation controlled by me, and allows me to make mapping changes as needed; but in theory you could have developers set all events this way (but then if there are issues you need a new app build and to deploy that build to the stores, then wait for users to upgrade)