Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      CodeSOD: A Unique Way to Primary Key

      July 22, 2025

      BrowserStack launches Figma plugin for detecting accessibility issues in design phase

      July 22, 2025

      Parasoft brings agentic AI to service virtualization in latest release

      July 22, 2025

      Node.js vs. Python for Backend: 7 Reasons C-Level Leaders Choose Node.js Talent

      July 21, 2025

      The best CRM software with email marketing in 2025: Expert tested and reviewed

      July 22, 2025

      This multi-port car charger can power 4 gadgets at once – and it’s surprisingly cheap

      July 22, 2025

      I’m a wearables editor and here are the 7 Pixel Watch 4 rumors I’m most curious about

      July 22, 2025

      8 ways I quickly leveled up my Linux skills – and you can too

      July 22, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025
      Recent

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025

      Zero Trust & Cybersecurity Mesh: Your Org’s Survival Guide

      July 22, 2025

      Execute Ping Commands and Get Back Structured Data in PHP

      July 22, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025
      Recent

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025

      “I don’t think I changed his mind” — NVIDIA CEO comments on H20 AI GPU sales resuming in China following a meeting with President Trump

      July 22, 2025

      Galaxy Z Fold 7 review: Six years later — Samsung finally cracks the foldable code

      July 22, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Part 2 – Marketing Cloud Personalization and Mobile Apps: Tracking Items

    Part 2 – Marketing Cloud Personalization and Mobile Apps: Tracking Items

    June 25, 2025

    In the first part of this series, we covered how to connect a mobile app to Marketing Cloud Personalization using Salesforce’s Mobile SDK. In this post, we’ll explore how to send catalog items from the mobile app to your dataset.

    What’s new on the DemoApp?

    Since the last post, I made some changes in the app. The app is connected to a free NASA API where takes information from the Mars Rover Photos connection. This connection returns an array of images taken on a specific earth’s date. For the demo purposes I’m only using the first record on that array. This  API is designed to collect image data gathered by NASA’s Curiosity, Opportunity, and Spirit rovers on Mars. The API make it more easily available to other developers, educators, and citizen scientists.

    The app has two different views, the main view and the display image view. In the main view, the user picks the Earth’s date and the app sends it to the API to retrieve a picture. The second view displays the picture along with some information (see image below). The goal here is to send the item (the picture and its information) to Personalization.

    Simulator Screenshot Iphone 16 Pro

     

    The role of Personalization’s Event API

    Marketing Cloud Personalization provides an Event API that sources use to send event data to the platform, where the event pipeline processes it. Then you can return Campaigns data that can be served to the end user. Developers cannot use of this API to handle mobile application events.

    “The Personalization Mobile SDK has separate functionality used for mobile app event processing, with built-in features that are currently unavailable through the Event API.”

    So, we can eliminate possibility to use the Event API in this use case.

    Tracking Items

    Tracking items is an important part of any Personalization implementation. Configure the Catalog Object so that it log and event when a user has viewed productFor example, imagine you have an app that sells the sweaters you knit. You want to know how many users go to “Red and Blue Sweater” product. With that information you can promote other products that those users might like, so they will be more likely to buy from you.

    There are two ways to track items and actions. Track catalog objects like Products, Articles, Blogs and Categories (which are the main catalog objects in Personalization) and you can also add Tags as a related catalog objects for those I name before.

    You can also track actions like AddToCard, RemoveFromCart and Purchase.

     

    Process Catalog Objects/Item Data

    In order to process the catalog and item data we are going to sent from our mobile application, we need to activate the Process Item Data from Native Mobile Apps . This option will make it possible for Personalization to process the data. By default Personalization ignores all the mobile catalog data that it receives.

    To activate this functionality, hover over SETTING > GENERAL SETUP > ADVANCE OPTIONS > Activate Process Item Data from Native Mobile Apps

    Process Item Data From Native Mobile Apps configuration inside Salesforce Marketing Cloud Personalization

    The SDK currently works for Products, Articles and Blogs, those are called Items. They will be able to track purchases, comments, or views. They also will be able to relate with other catalog objects like brand, category and keyword.

    Methods to process item data

    The following methods are used to track the action of the users viewing and Item or the detail of and item. The web comparison for these methods are the SalesforceInteractions.CatalogObjectInteractionName.ViewCatalogObject and the SalesforceInteractions.CatalogObjectInteractionName.ViewCatalogObjectDetail

    viewItem: and viewItem:actionName:

    These methods track when a user views an item. Personalization will automatically track the time spent viewing the item while the context, app, and user is active. The item will remain the one viewed until this method or viewItemDetail  are called again. See documentation Here

    The second method have the actionName  parameter that is use for different action name to distinguish this View Item.

    evergageScreen?.viewItem(_ item: EVGItem?)
    evergageScreen?.viewItem(_ item: EVGItem?, actionName: String?)

    View Item Interaction in the Event Stream:

    Event Detail Interaction

    View Item interaction using the actionName parameter

    Event Detail Interaction with Action Field parameter

    EVGItem is an abstract base class. An item is something in the app that users can view or otherwise engage with. Classes like EVGProduct or EVGArticle inherits from this class

    The question mark at the end of String and EVGItem  means that the value is optional or can be  nil . The last one can happen to the EVGItem  if have some invalid value.

    viewItemDetail: and viewItemDetail:actionName:

    These methods track details when a user views an item, such as looking at other product images or opens the specifications tab. Personalization will automatically track the time spent viewing the item while the context, app, and user is active. The item will remain the one viewed until this method or viewItem:  are called again.

    The second method have the actionName  parameter that its use for different action name to distinguish this View Item Detail.

    evergageScreen?.viewItemDetail(_ item: EVGItem?)
    evergageScreen?.viewItemDetail(_ item: EVGItem?, actionName: String?)

    View Item Detail interaction in the Event Stream:

    Event Item Detail interaction

    View Item Detail interaction but using the actionName parameter:

    Event Item Detail With Action interaction

    Now we have define those EVGItem objects with the actual catalog object we want to track Blog / Category / Articles / Product.

     

    The EVGProduct Class

    By definition, a Product is an item that a business can sell to users.  Products can be added to EVGLineItem objects when they have been ordered by the user.

    We have a group of initializers we can use to create an Evergage product and send it back to Personalization. The EVGProduct class have variety of methods we can use. For this post I will show the most relevant to use.

    Something important to remember is that in order to use classes like EVGProduct or EVGArticle, we need to import the Evergagelibrary.

    The productWithId: method

    The most basic of them all, we just need to pass the ID of the product and that’s it. This can be useful if we don’t want to provide too much information.

    evergageScreen?.viewItem(EVGProduct.init(id: "p123"))

    The productWithId:name:price:url:imageUrl:evgDescription: method

    Builds an EVGProduct, including many of the commonly used fields. This constructor use the id, name, price, url, image and description fields of the Product catalog object.

    As a reminder , I’m building my Product catalog object using the images from the Mars Rover Photos with some other attributes that we got in the response from the API

    For this constructor, the values I’m sending in the parameters are:

    • The ID of the image returned in the JSON
    • The full name of the camera that took the photo
    • A price of 10 (just because this needs a value here)
    • The image URL returned in the JSON
    • A description I made using the earth, landing and launching dates.

    All I just have to do is pass the new item using any of the method we use to track item data.

    let item : EVGItem = EVGProduct.init(id:String(id),
                                          name: name,
                                          price: 10,
                                          url: url,
                                          imageUrl: imageUrl,
                                          evgDescription: "This is a photo taken form (roverName). Earth Date: (earthDate). Landing Date: (landingDate). Launch Date: (launchDate)")
            
     evergageScreen?.viewItemDetail(item)

     

    The item declaration ir correct since EVGProduct inherits from EVGItem.

    After populating the information, the catalog object will look like this inside Marketing Cloud Personalization:

    Product Catalog Object Item inside SFMC Personalization

    The productFromJSONDictionary: method

    As the name says it creates an EVGProduct from the provided JSON dictionary. A JSON dictionary is an array of key-value pair in the form [String : Any] where you add attributes from the Product catalog object.

    let productDict : [String : Any] = [
               "_id": String(id),
               "url": url,
               "name": name,
               "imageUrl": imageUrl,
               "description": "This is a photo taken form (roverName). Earth Date: (earthDate). Landing Date: (landingDate). Launch Date: (launchDate)",
               "price": 10,
               "currency": "USD",
               "inventoryCount": 2
    ]
    
    let itemJson: EVGItem? = EVGProduct.init(fromJSONDictionary: productDict)
    evergageScreen?.viewItemDetail(itemJson, actionName: "User did specific action")

    Then you can initialize the EVGProduct object with the constructor that uses the fromJSONDictionary parameter.

    The last step here will be sent the action with the viewItemDetail method.

    This is how the record should look like after the creation in the dataset.

    Product created using JSON method

     

    Final Class

    This is how our class will look with the methods to sent the item interactions.

    Swift class code with the method to sent interaction to Personalization

    Bonus: How to set attributes values?

    Imagine you also want to set attributes to sent to personalization like first name, last name, email address or zip code. If you want to do that, all you need to do its to use the setUserAttribute method inside the AppDelegate class or after the user logs in. We used this class to pass the id of the user and to set the datasetID.

    After the user logs in you can pass the information you need to personalization The setUserAttribute:forName: sets an attribute (a name/value pair) on the user. The next event will send the new value to the Personalization dataset.

    evergage.setUserAttribute("attributeValue", forName: "attributeName")
    
    //Following the example
    evergage.userId = evergage.anonymousId
    evergage.setUserAttribute("Raul", forName: "firstName")
    evergage.setUserAttribute("Juliao", forName: "lastName")
    evergage.setUserAttribute("raul@gmail.com", forName: "emailAddress")
    evergage.setUserAttribute("123456", forName: "zipCode")

    The set attributes event:

    Event interaction setting user information.

    The Customer’s Profile view

    Customer Profile View pointing the newly set attributes

     

    Conclusion: Syncing Your Mobile App’s Catalog with Personalization

    To wrap things up, setting up Articles, Blogs, and Categories works pretty much the same way as setting up Products. The structure stays consistent—you just have to keep in mind that each one belongs to a different class, so you’ll need to tweak things slightly depending on what you’re working with.

    That said, one big limitation to note is that you can’t send custom attributes in catalog objects, even if you try using the JSON dictionary method. I tested a few different approaches, and unfortunately, it only supports the default attributes.

    Also, the documentation doesn’t really go into detail about using other types of catalog objects outside of Articles, Blogs, Products, and Categories. It’s unclear if custom catalog objects are supported at all through the mobile SDK, which makes things a bit tricky if you’re looking to do something more advanced.

    In part 3 we are going to take a look at how to set push notifications and mobile campaigns.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleTracking Cache Activity with Laravel Events
    Next Article Elevating API Automation: Exploring Karate as an Alternative to Rest-Assured

    Related Posts

    Development

    GPT-5 is Coming: Revolutionizing Software Testing

    July 22, 2025
    Development

    Win the Accessibility Game: Combining AI with Human Judgment

    July 22, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    My top 6 browsers after trying nearly every one (spoiler: none are Chrome)

    News & Updates

    AMD Radeon graphics driver brings FSR 4 support to The Elder Scrolls IV: Oblivion Remastered and Assassin’s Creed Shadows

    News & Updates

    Unlocking the Power of MLflow 3.0 in Databricks for GenAI

    Development

    Design system annotations, part 2: Advanced methods of annotating components

    News & Updates

    Highlights

    ChromeOS M137 update boosts accessibility, sound, and IT management tools

    June 12, 2025

    If you manage Chromebooks—or use one yourself—ChromeOS M137 is now out with a few upgrades.…

    CVE-2025-7824 – Jinher OA XML External Entity Reference (XXE) Vulnerability

    July 19, 2025

    CVE-2025-6273 – WebAssembly wabt Reachable Assertion Vulnerability

    June 19, 2025

    These 6 lightweight Linux apps let older PCs run blazing fast

    April 21, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.