iOS SDK clearVars() usage

dhana_prakash_m

15-10-2015

Hi,

       I would like to understand the usage of clearVars() method from 3.x Omniture iOS SDK. As the measurement API provides singleton object, I was under impression that we should invoke clearVars() method for every track call. But the given example doesn't have invoke clearVars() method. It would be nice if someone can explain the scenarios of when we should invoke clearVars() method.

Regards,

Dhana Prakash

Accepted Solutions (1)

Accepted Solutions (1)

meatcouch

Employee

15-10-2015

Dhana,

 

clearVars() is intended to be used to reset all "persistent state" variables, i.e. variables set with the setEvar/setProp/etc calls.  We would strongly recommend that you use the track methods that package the data with the call (trackAppState to attach context data, or track to attach context data and variables), as this is the safest and most-efficient way to send the data.

 

You can find the documentation on all methods here.

 

Regards,

Peter Fransen

Mobile Engineering Team Lead

Answers (5)

Answers (5)

dhana_prakash_m

15-10-2015

Hi Pete,

    Thanks a lot for clarifying that we can send prop and evar as the part of dictionary and it doesn't require any processing rules to be set. I will run few tests to make sure that I got this right and will get back to you.

    Appreciate your guidance on this!!!

 

Regards,

Dhana Prakash

meatcouch

Employee

15-10-2015

Dhana,

 

If you use the track/trackLink call, they both support an additional dictionary of key value pairs called "variableOverrides".  This dictionary allows you to bulk-set any of the standard vars for that call only, using their standard names (eVar1, prop2, etc).  This would get you the benefit of the one-time data, but not require the use of processing rules.  The drawback is you do not get to use the convenience methods (trackState, etc), and those calls would have to be generated manually via the variableOverrides (i.e., by setting "pageName" for the page name to generate a trackState equivalent call).

 

-pete

dhana_prakash_m

15-10-2015

Hi Pete,

    I think, you are suggesting to remove the setProp/setEvar method calls and have the corresponding processing rules set at Omniture site to capture the data from context data from the hit. Please correct me if my understanding is not correct.

    Unfortunately, the existing code has the given sequence (4 steps) without processing rules. If we can't add the processing rules now, should we have to live with all the 4 steps? 

 

Thanks,

Dhana Prakash

meatcouch

Employee

15-10-2015

Dhana,

 

Give your sequence of events, I'd recommend a slight modification:

1. call setPersistentContextData to set the data that will be common across all calls.

2. invoke track/trackLink and send the call-specific evars/props as part of the variable overrides dictionary.

 

This will ensure that the evars/props are only sent with the specific call(especially important in any modern, multi-threaded environment), and will remove the need to call clearVars or set your persistent data more than once.

 

-Pete

dhana_prakash_m

15-10-2015

Hi Pete,

         Thank you very much for your prompt response. Currently we are using trackXXX methods in the below sequence. I would like to understand whether #1 is required here (we are using v3.3 Omniture SDK).  I am little confused here because if we call #1, we loose persistentContextData which forces us to go for #2 (which is quite opposite to persistent concept). 

1. Call clearVars()

2. Call setPersistentContextData to add the common data that has to be sent in each call (ex:- App Version, OS Version,.....)

3. Set the data specific data using setProp/setEvar/...

4. invoke trackAppState/trackEvents/track/trackLinkURL method based on the user navigation/action

Regards,

Dhana Prakash M