1.5.5 • Published 1 year ago

@convertcom/tracking-types v1.5.5

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
1 year ago

Tracking Script Types

Usage

  1. Install package: npm install --save @convertcom/tracking-types
  2. 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

TypeObject
ConvertWindowwindow
Convertwindow.convert
ConfigResponseDatawindow.convert.data
CurrentDatawindow.convert.currentData
HistoricalDatawindow.convert.historicalData
ProcessQueuewindow._conv_q
ProcessQueueItemAPI method pushed to window._conv_q (see available API method types)

Available API Method Types

Can only be pushed into Convert Queue _conv_q

TypeThe what PropertyThe params Property
AddListeneraddListener{event: LifeCycleEvent; handler: (event?: Record<string, any>) => void;}
Runrun{resetData?: boolean;}
TriggerExperienceVariationtriggerExperienceVariation{experienceId: string; variationId: string;}
AssignVariationassignVariation{experienceId: string; variationId: string;}
ExecuteMissingDataExperiencesexecuteMissingDataExperiences{visitorId?: string;}
CheckExperiencescheckExperiences{visitorId?: string;}
DoNotRunExperiencesdoNotRunExperiences
DisableExperiencedisableExperience{experienceId: string \| Array<string>;}
EnableExperienceenableExperience{experienceId: string \| Array<string>}
DisableVariationdisableVariation{experienceId: string; variationId: string}
EnableVariationenableVariation{experienceId: string; variationId: string}
ExecuteExperimentexecuteExperiment{experienceId: string; visitorId?: string; logLevel?: LogLevel;}
TriggerConversiontriggerConversion{goalId: string; experienceId?: string; visitorId?: string;}
TriggerConversionstriggerConversions{goalId: Array<string>; experienceId?: string; visitorId?: string;}
PushRevenuepushRevenue{goalId?: string; transactionId: string; amount: number \| string; productsCount?: number; fromAutoPickRevenue?: string; forceMultiple?: boolean;}
RecheckGoalsrecheckGoals
PlaceVisitorIntoSegmentplaceVisitorIntoSegment{segmentId: string; visitorId?: string;}
CheckSegmentscheckSegments{visitorId?: string;}
CheckSegmentLoopedcheckSegmentLooped{segmentId: string; visitorId?: string;}
ShowBodyshowBody
ForceCookieSecureforceCookieSecure{secure: boolean;}
SetParameterssetParameters{data: ConvertData;}
SetIntegrationVariablesetIntegrationVariable{integration: IntegrationProviderExtra; customVariable: IntegrationCustomVariable;}
ConsentRequiredconsentRequired{runExperiences?: boolean;}
ConsentGivenconsentGiven
TriggerLocationtriggerLocation{locationId: string;}
EnablePreviewenablePreview{enableTracking?: boolean;}
DisablePreviewdisablePreview

Public API Methods

Return TypeMethod
VisitorDatawindow.convert.getAllVisitorData()
VisitorDatawindow.convert.getCurrentVisitorData()
UserDatawindow.convert.getUserData()
VisitorSegmentswindow.convert.getDefaultSegments()
Record<string, any>window.convert.getVisitorSegments()
voidwindow.convert.redirect({url, caseSensitive}: {url: string; caseSensitive?: boolean;})
voidwindow.convert.refresh({consentRequired}: {consentRequired?: boolean;})
stringwindow.convert.cookieUrl({url}: {url: string;})
ReadyReturnwindow.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

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