Expand my Community achievements bar.

SOLVED

Context data and variables

Avatar

Level 3

We had a app developer here for a couple setting up adobe tracking for our new app (before I came onboard, no idea what happened).

He left us with about 30 or so events and documentation that looks like this:

       

event55Select Your Installation Manuallya.action=team.selectyourinstallationmanuallySelect Your Installation Manually[contextData setObject:@("select your installation manually" forKey:@"selectyourinstallationmanually"];Toggle
event76Enable SMS Notificationsa.action=team.enablesmsnotificationsEnable SMS Notifications[contextData setObject:@("enable sms notifications" forKey:@"team.enablesmsnotifications"];Toggle
event59Promotional Updatesa.action=promotionalupdatesPromotional Updates[contextData setObject:@("promotionalupdates" forKey:@"team.promotionalupdates"];Checkbox

But my dev team said that [contextData setObject:@("enable mail notifications" forKey:@"aafes.mailnotifications"]; doesn't make sense and wouldn't implement it. I've also never seen it written this way but wanted to see if it does to anyone else or what is the right way to this up? (I've substituted "team" for the company name)

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi jha0024, the example above you provided above would be the correct syntax. For example: instead of doing

[contextData setObject:@"login_status" forKey:@"mobile.login_status"];

you may do

contextData['mobile.login_status'] = 'login_status'

View solution in original post

8 Replies

Avatar

Employee

Hi andersonjh​ - apologies for the delayed response. I'm not completely sure what you're trying to do. Can I trouble you provide a little more context and perhaps some end-results of what you're trying to accomplish so we can get you a prompt response?

Avatar

Level 1

Absolutely. We're trying to implement context data variables into our mobile app. Historically, I've only seen script like this,

s.contextData[‘mobile.login_status’] = ‘Logged In’;

but the consultant gave us implementation specs that looked like the first post. I'm not a developer so I want to be careful but, in my understanding, his technical implementation specs can't actually be used. Meaning, we can't set a variable for when people login as

[contextData setObject:@("login_status" forKey:@"mobile.login_status"];

Or can we? Which of these two examples can actually be coded into the app and set as a data element? Or can neither be used?

Avatar

Employee

Hi jha0024​ - May I ask if you are asking about the Android or iOS app implementation? If it is iOS, is your application written in Swift or Objective-C.

[contextData setObject] is Objective-C syntax. The example you provided: s.contextData[‘mobile.login_status’] = ‘Logged In’, looks like a Swift syntax.

Avatar

Level 1

Great to know.

It's actually being written in React Native. Do you know the syntax for that?

Avatar

Correct answer by
Employee

Hi jha0024, the example above you provided above would be the correct syntax. For example: instead of doing

[contextData setObject:@"login_status" forKey:@"mobile.login_status"];

you may do

contextData['mobile.login_status'] = 'login_status'

Avatar

Level 1

Thanks. 2 questions. do i need to have s. or p. etc in front of the contextData? and = 'login_status" can be replaced by whatever term we define as the login status or not? such as 'Logged In" or does it need to be = 'login_status'  ?

Avatar

Employee

1. It depends on where you are inserting this line of code in the application. The contextData variable may be a field of another object (s or p). The developers should recognize whether they need it or not.

2. Yes, I used 'login_status' in my example to be consistent with the String used in the setObject call from Objective-C. In actual implementation it is likely that it is a value of current login status, for this particular example.