We use cookies and similar technologies to improve your experience, analyse traffic, and personalise content. You can accept all cookies or reject non-essential ones.
यह गाइड मोबाइल प्लेटफ़ॉर्म — React Native, Flutter, iOS (Swift), और Android (Kotlin) — पर SurveyAnalytica Clickstream SDK को इंस्टॉल करने और उपयोग करने के बारे में बताती है। वेब प्रोजेक्ट्स के लिए, Web SDK guide देखें।
शुरू करने से पहले, अपनी API Key और Endpoint URL प्राप्त करने के लिए workflow setup पूरा करें।
npm install @surveyanalytica/clickstream-rn @react-native-async-storage/async-storage
अपनी ऐप शुरू होने पर, किसी भी नेविगेशन के रेंडर होने से पहले, init को एक बार कॉल करें:
import { SAClickstream } from '@surveyanalytica/clickstream-rn';
await SAClickstream.init('YOUR_WORKFLOW_ID', 'YOUR_API_KEY', {
endpoint: 'YOUR_ENDPOINT_URL'
});
// Screen view (call from useEffect in each screen component)
SAClickstream.page('ProductDetailScreen');
// Custom event
SAClickstream.track('add_to_cart', { productId: 'sku-9821', quantity: 2 });
// Identify after login
SAClickstream.identify('contact-id-from-your-backend');
// Revoke consent
SAClickstream.setConsent(false);
flutter pub add sa_clickstream
runApp से पहले main() में initialize को कॉल करें:
import 'package:sa_clickstream/sa_clickstream.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SAClickstream.initialize(
workflowId: 'YOUR_WORKFLOW_ID',
apiKey: 'YOUR_API_KEY',
saEndpoint: 'YOUR_ENDPOINT_URL',
);
runApp(const MyApp());
}
स्क्रीन ट्रांज़िशन को अपने आप ट्रैक करने के लिए अपने MaterialApp में SARouteObserver जोड़ें:
MaterialApp(
navigatorObservers: [SARouteObserver()],
...
)
SAClickstream.track('button_tapped', properties: {'label': 'Buy Now'});
SAClickstream.page('CheckoutScreen');
SAClickstream.identify('contact-id-from-your-backend');
SAClickstream.setConsent(false);
Swift Package Manager — Xcode में File → Add Package Dependencies पर जाएँ और यह दर्ज करें:
https://github.com/aphougat/clickstream-ios
वर्शन 1.0.0 या उसके बाद का चुनें।
CocoaPods — अपने Podfile में जोड़ें:
pod 'SAClickstream', '~> 1.0'
फिर pod install चलाएँ।
पहला scene दिखने से पहले अपने AppDelegate या @main स्ट्रक्ट में initialize को कॉल करें:
import SAClickstream
SAClickstream.initialize(
workflowId: "YOUR_WORKFLOW_ID",
apiKey: "YOUR_API_KEY",
saEndpoint: "YOUR_ENDPOINT_URL"
)
// In viewDidAppear
SAClickstream.page("ProductDetailViewController")
// Custom event
SAClickstream.track("button_tapped", properties: ["label": "Buy Now"])
// Identify after login
SAClickstream.identify("contact-id-from-your-backend")
// Revoke consent
SAClickstream.setConsent(false)
अपने build.gradle.kts में GitHub Packages रिपॉज़िटरी और डिपेंडेंसी जोड़ें:
repositories {
maven {
url = uri("https://maven.pkg.github.com/aphougat/clickstream-android")
credentials {
username = providers.gradleProperty("gpr.user").orElse("").get()
password = providers.gradleProperty("gpr.token").orElse("").get()
}
}
}
dependencies {
implementation("com.surveyanalytica:clickstream-android:1.0.0")
}
अपने Application.onCreate() में initialize को कॉल करें:
import com.surveyanalytica.clickstream.SAClickstream
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
SAClickstream.initialize(
context = this,
workflowId = "YOUR_WORKFLOW_ID",
apiKey = "YOUR_API_KEY",
saEndpoint = "YOUR_ENDPOINT_URL"
)
}
}
// In Activity.onResume or Fragment.onResume
SAClickstream.page("ProductDetailActivity")
// Custom event
SAClickstream.track("button_tapped", mapOf("label" to "Buy Now"))
// Identify after login
SAClickstream.identify("contact-id-from-your-backend")
// Revoke consent
SAClickstream.setConsent(false)
सभी प्लेटफ़ॉर्म पर SDK एक ही तरीके से काम करता है: इवेंट लोकली क्यू किए जाते हैं और हर 500 मिलीसेकंड में फ्लश होते हैं, या जब 20 इवेंट जमा हो जाएँ तो तुरंत फ्लश हो जाते हैं। हर फ्लश एक ही बैच रिक्वेस्ट भेजता है। असफल रिक्वेस्ट को बढ़ती हुई देरी के साथ तीन बार तक फिर से प्रयास किया जाता है। पहले लॉन्च पर असाइन की गई अनाम पहचान सेशन्स में बनी रहती है, जिससे यूज़र्स की पहचान लगातार बनी रहती है जब तक आप identify को कॉल नहीं करते।
initialize / init को कॉल किया गया है।Android SDK को GitHub Packages के ज़रिए वितरित किया जाता है। सुनिश्चित करें कि आपके gradle.properties या CI एनवायरनमेंट में एक वैध gpr.user और gpr.token (read:packages अनुमति वाला GitHub personal access token) शामिल है।