Skip to content

Commit df6f03c

Browse files
authored
Merge pull request #4963 from segmentio/ashton-huxtable-patch-3
Add context section to iOS docs
2 parents 879b01d + f4ef356 commit df6f03c

File tree

1 file changed

+40
-0
lines changed
  • src/connections/sources/catalog/libraries/mobile/ios

1 file changed

+40
-0
lines changed

src/connections/sources/catalog/libraries/mobile/ios/index.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,46 @@ Analytics.shared().enable()
580580
> warning ""
581581
> If you disable the Segment SDK in response to user opt-out, all Segment method invocations (Track, Screen, Identify, etc) are ignored. However, this does not disable any destination SDKs that you bundled along with Segment. You should consult the vendor documentation for those destinations, and invoke the corresponding `disable` methods for each packaged SDK to ensure that any automatic data collection stops.
582582
583+
## Context
584+
Context is a dictionary of extra information you can provide about a specific API call. You can add any custom data to the context dictionary that you want to have access to in the raw logs. Some keys in the context dictionary [have semantic meaning and are collected for you automatically](/docs/connections/spec/common/#context), such as information about the user’s device.
585+
586+
The example below shows a track call where campaign data is added to context:
587+
588+
{% codeexample %}
589+
{% codeexampletab Swift %}
590+
```swift
591+
Analytics.shared().track("Product Viewed", properties: nil, options: ["context": ["campaign": ["medium": "email", "name": "testCampaign", "source": "testSource"]]])
592+
```
593+
{% endcodeexampletab %}
594+
{% codeexampletab Objective-C %}
595+
```objc
596+
[[SEGAnalytics sharedAnalytics] track:@"Product Viewed"
597+
properties:nil
598+
options:@{ @"context": @{ @"campaign": @{ @"medium": @"email", @"name": @"testCampaign", @"source": @"testSource" }}}];
599+
```
600+
{% endcodeexampletab %}
601+
{% endcodeexample %}
602+
603+
You can also override any context that Segment automatically collects.
604+
605+
The example below shows a track call where locale is overwritten to a specific value:
606+
607+
{% codeexample %}
608+
{% codeexampletab Swift %}
609+
```swift
610+
Analytics.shared().track("Product Viewed", properties: nil, options: ["context": ["locale": "en"]])
611+
```
612+
{% endcodeexampletab %}
613+
{% codeexampletab Objective-C %}
614+
```objc
615+
[[SEGAnalytics sharedAnalytics] track:@"Product Viewed"
616+
properties:nil
617+
options:@{ @"context": @{ @"locale": @"en" }}];
618+
```
619+
{% endcodeexampletab %}
620+
{% endcodeexample %}
621+
622+
583623
584624
## Selecting Destinations
585625

0 commit comments

Comments
 (0)