[Swift] Analytics - Product variable implementation is not in documentation

Avatar

Avatar
Validate 1
Level 1
kevinj52562561
Level 1

Likes

3 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
kevinj52562561
Level 1

Likes

3 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
kevinj52562561
Level 1

20-08-2019

Hello everyone!

I have a quick question about swift syntax to implement products info in analytics.

In this document: Product variable - Adobe Experience Platform Mobile SDKs

We only have info about Obective-C implementation.

Can anyone help me on the syntax for Swift? Can the documentation be uptated?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 1
Employee
ArjunBhadra
Employee

Likes

2 likes

Total Posts

2 posts

Correct reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile

Avatar
Boost 1
Employee
ArjunBhadra
Employee

Likes

2 likes

Total Posts

2 posts

Correct reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile
ArjunBhadra
Employee

20-08-2019

Hi Jennifer Andrews Adobe​,

Thanks for verifying the code, good catch it has to be  var contextData: [String : String] = [:]

Will update the documentation accordingly.

Thanks,
Arjun

Answers (6)

Answers (6)

Avatar

Avatar
Validate 1
Level 1
kevinj52562561
Level 1

Likes

3 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
kevinj52562561
Level 1

Likes

3 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
kevinj52562561
Level 1

21-08-2019

Hi Jennifer Andrews Adobe, arjunbhadra,

Thanks foy your quick answers!

Kevin

Avatar

Avatar
Validate 1
Employee
Jen_Andrews
Employee

Likes

57 likes

Total Posts

61 posts

Correct reply

36 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Employee
Jen_Andrews
Employee

Likes

57 likes

Total Posts

61 posts

Correct reply

36 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
Jen_Andrews
Employee

20-08-2019

kevinj52562561

The sample code above is when using Product variable with Merchandising Variable.

The link Arjun provided above shows documentation for a Product variable only.

arjunbhadra

I get a compile error with

var contextData: [AnyHashable : Any] = [:]

Cannot convert value of type '[AnyHashable : Any]' to expected argument type '[String : String]?'

I change to

  var contextData: [String : String] = [:]

Compiled successfully and received the correct information in the hit sent to Analytics.

Can you confirm that is the correct method?

Thanks,
Jen

Avatar

Avatar
Boost 1
Employee
ArjunBhadra
Employee

Likes

2 likes

Total Posts

2 posts

Correct reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile

Avatar
Boost 1
Employee
ArjunBhadra
Employee

Likes

2 likes

Total Posts

2 posts

Correct reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile
ArjunBhadra
Employee

20-08-2019

Hi Kevin,

The swift syntax would be as follows:

//create a context data dictionary

// add products, a purchase id, a purchase context data key, and any other data you want to collect.

// Note the special syntax for products

var contextData = ["&&events" : "event1", "&&products" : ";Running Shoes;1;69.95;event1=5.5;eVar1=Merchandising,;Running Socks;10;29.99", "m.purchaseid" : "1234567890", "m.purchase" : "1"]

// send the tracking call - use either a trackAction or TrackState call.

// trackAction example:

ACPCore.trackAction("purchase", data:contextData)

// trackState example:

ACPCore.trackState("Order Confirmation", data: contextData)

Refer this link : https://aep-sdks.gitbook.io/docs/using-mobile-extensions/adobe-analytics#set-products-variable

Thanks for pointing it out, we will update our documentation to point to the correct sample.

Thanks,

Arjun

AEP SDK Team

Avatar

Avatar
Validate 1
Level 1
kevinj52562561
Level 1

Likes

3 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
kevinj52562561
Level 1

Likes

3 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
kevinj52562561
Level 1

20-08-2019

Hi Jantzen,

SKD is not implemented yet so it will be at least Core 2.3.2 and Analytics 2.1.2

Thanks!

Avatar

Avatar
Validate 1000
Community Manager
jantzen_belliston-Adobe
Community Manager

Likes

339 likes

Total Posts

2,338 posts

Correct reply

819 solutions
Top badges earned
Validate 1000
Springboard
Validate 500
Validate 250
Validate 100
View profile

Avatar
Validate 1000
Community Manager
jantzen_belliston-Adobe
Community Manager

Likes

339 likes

Total Posts

2,338 posts

Correct reply

819 solutions
Top badges earned
Validate 1000
Springboard
Validate 500
Validate 250
Validate 100
View profile
jantzen_belliston-Adobe
Community Manager

20-08-2019

Great! I wanted to make sure I move this question to the correct mobile community. Since you haven't implemented yet, I'm assuming you'll be using V5 of our SDK so I'll move this question to the Adobe Experience Platform SDKs​ community. You are also welcome to browse the legacy Adobe Experience Cloud Mobile​ community for answers, just know that there are major differences between the two so be sure to verify any information found in the latter community.

Avatar

Avatar
Validate 1000
Community Manager
jantzen_belliston-Adobe
Community Manager

Likes

339 likes

Total Posts

2,338 posts

Correct reply

819 solutions
Top badges earned
Validate 1000
Springboard
Validate 500
Validate 250
Validate 100
View profile

Avatar
Validate 1000
Community Manager
jantzen_belliston-Adobe
Community Manager

Likes

339 likes

Total Posts

2,338 posts

Correct reply

819 solutions
Top badges earned
Validate 1000
Springboard
Validate 500
Validate 250
Validate 100
View profile
jantzen_belliston-Adobe
Community Manager

20-08-2019

Can you confirm which version of the SDK you are using?