1.5.5 • Published 9 months ago
@convertcom/tracking-types v1.5.5
Tracking Script Types
Usage
- Install package:
npm install --save @convertcom/tracking-types
Import types, for example:
import { 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 what Property | The params Property |
---|---|---|
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;} |
CheckExperiences | checkExperiences | {visitorId?: string;} |
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; logLevel?: LogLevel;} |
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;} |
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 {
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.5.5
9 months ago
1.5.4
10 months ago
1.5.3
10 months ago
1.5.2
10 months ago
1.5.1
10 months ago
1.5.0
10 months ago
1.4.1
10 months ago
1.3.2
10 months ago
1.4.0
10 months ago
1.3.1
10 months ago
1.3.0
10 months ago
1.2.0
1 year ago
1.1.0
1 year ago
1.2.1
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago