1.6.1 • Published 10 months ago
@convertcom/tracking-types v1.6.1
Tracking Script Types
Usage
- Install package: npm install --save @convertcom/tracking-types
- Import types, for example: - import type { AddListener, CurrentData, LifeCycleEvent } from '@convertcom/tracking-types'; const {experiences} = window.convert.currentData as CurrentData; console.log('experiences:', experiences); const onGoalsEvaluated: AddListener = { what: 'addListener', params: { event: LifeCycleEvent.SNIPPET_GOALS_EVALUATED, handler: (event) => { console.log('on goals evaluated:', event); } } }; window._conv_q = window._conv_q || []; window._conv_q.push(onGoalsEvaluated);
Available Types
| Type | Object | 
|---|---|
| ConvertWindow | window | 
| Convert | window.convert | 
| ConfigResponseData | window.convert.data | 
| CurrentData | window.convert.currentData | 
| HistoricalData | window.convert.historicalData | 
| ProcessQueue | window._conv_q | 
| ProcessQueueItem | API method pushed to window._conv_q(see available API method types) | 
Available API Method Types
Can only be pushed into Convert Queue
_conv_q
| Type | The whatProperty | The paramsProperty | 
|---|---|---|
| AddListener | addListener | {event: LifeCycleEvent; handler: (event?: Record<string, any>) => void;} | 
| Run | run | {resetData?: boolean;} | 
| TriggerExperienceVariation | triggerExperienceVariation | {experienceId: string; variationId: string;} | 
| AssignVariation | assignVariation | {experienceId: string; variationId: string;} | 
| ExecuteMissingDataExperiences | executeMissingDataExperiences | {visitorId?: string; triggerIntegrations?: boolean} | 
| CheckExperiences | checkExperiences | {visitorId?: string; triggerIntegrations?: boolean} | 
| DoNotRunExperiences | doNotRunExperiences | |
| DisableExperience | disableExperience | {experienceId: string                                                                                                                               \| Array<string>;} | 
| EnableExperience | enableExperience | {experienceId: string                                                                                                                               \| Array<string>} | 
| DisableVariation | disableVariation | {experienceId: string; variationId: string} | 
| EnableVariation | enableVariation | {experienceId: string; variationId: string} | 
| ExecuteExperiment | executeExperiment | {experienceId: string; visitorId?: string; triggerIntegrations?: boolean; logLevel?: LogLevel;} | 
| ExecuteExperienceLooped | executeExperienceLooped | {locationId?: string; experienceId: string; visitorId?: string; triggerIntegrations?: boolean} | 
| TriggerConversion | triggerConversion | {goalId: string; experienceId?: string; visitorId?: string;} | 
| TriggerConversions | triggerConversions | {goalId: Array<string>; experienceId?: string; visitorId?: string;} | 
| PushRevenue | pushRevenue | {goalId?: string; transactionId: string; amount: number \| string; productsCount?: number; fromAutoPickRevenue?: string; forceMultiple?: boolean;} | 
| RecheckGoals | recheckGoals | |
| PlaceVisitorIntoSegment | placeVisitorIntoSegment | {segmentId: string; visitorId?: string;} | 
| CheckSegments | checkSegments | {visitorId?: string;} | 
| CheckSegmentLooped | checkSegmentLooped | {segmentId: string; visitorId?: string;} | 
| ShowBody | showBody | |
| ForceCookieSecure | forceCookieSecure | {secure: boolean;} | 
| SetParameters | setParameters | {data: ConvertData;} | 
| SetIntegrationVariable | setIntegrationVariable | {integration: IntegrationProviderExtra; customVariable: IntegrationCustomVariable;} | 
| ConsentRequired | consentRequired | {runExperiences?: boolean;} | 
| ConsentGiven | consentGiven | |
| TriggerLocation | triggerLocation | {locationId: string; triggerIntegrations?: boolean} | 
| EnablePreview | enablePreview | {enableTracking?: boolean;} | 
| DisablePreview | disablePreview | 
Public API Methods
| Return Type | Method | 
|---|---|
| VisitorData | window.convert.getAllVisitorData() | 
| VisitorData | window.convert.getCurrentVisitorData() | 
| UserData | window.convert.getUserData() | 
| VisitorSegments | window.convert.getDefaultSegments() | 
| Record<string, any> | window.convert.getVisitorSegments() | 
| void | window.convert.redirect({url, caseSensitive}: {url: string; caseSensitive?: boolean;}) | 
| void | window.convert.refresh({consentRequired}: {consentRequired?: boolean;}) | 
| string | window.convert.cookieUrl({url}: {url: string;}) | 
| ReadyReturn | window.convert.ready() | 
Additional Examples
import type {
  AssignVariation,
  ExecuteExperience,
  IntegrationProviderExtra,
  LogLevel,
  SetIntegrationVariable,
  TriggerConversion,
  TriggerLocation,
  PushRevenue,
  Run
} from '@convertcom/tracking-types';
window._conv_q = window._conv_q || [];
const setIntegrationVariable: SetIntegrationVariable = {
  what: 'setIntegrationVariable',
  params: {
    integration: IntegrationProviderExtra.GOOGLE_TAG_MANAGER,
    customVariable: 'dataLayer4'
  }
};
const assignVariation: AssignVariation = {
  what: 'assignVariation',
  params: {
    experienceId: '123',
    variationId: '456'
  }
};
const executeExperience: ExecuteExperience = {
  what: 'executeExperience',
  params: {
    experienceId: '123',
    visitorId: "456",
    skipLocations: false;
    logLevel: LogLevel.INFO;
  }
};
const triggerLocation: TriggerLocation = {
  what: 'triggerLocation',
  params: {
    locationId: '123'
  }
};
const triggerConversion: TriggerConversion = {
  what: 'triggerConversion',
  params: {
    goalId: '123',
    experienceId: '456',
    visitorId: "789"
  }
};
const pushRevenue: PushRevenue = {
  what: 'pushRevenue',
  params: {
    goalId: '123',
    transactionId: '456',
    amount: 10,
    productsCount: 1,
    fromAutoPickRevenue: false,
    forceMultiple: false
  }
};
window._conv_q.push(setIntegrationVariable, assignVariation, executeExperience, triggerLocation, triggerConversion, pushRevenue);Credits
Copyright(c) 2024 Convert Insights, Inc.
1.6.1
10 months ago
1.6.0
11 months ago
1.5.6
12 months ago
1.5.5
1 year ago
1.5.4
1 year ago
1.5.3
1 year ago
1.5.2
1 year ago
1.5.1
1 year ago
1.5.0
1 year ago
1.4.1
1 year ago
1.3.2
1 year ago
1.4.0
1 year ago
1.3.1
1 year ago
1.3.0
1 year ago
1.2.0
1 year ago
1.1.0
1 year ago
1.2.1
1 year ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago