Options

Options

Options used when initializing Amplitude

OptionTypeDescriptionDefault
apiEndpointstringapi.amplitude.comEndpoint to send amplitude event requests to.
batchEventsstringfalseIf true, then events are batched together and uploaded only when the number of unsent events is greater than or equal to eventUploadThreshold or after eventUploadPeriodMillis milliseconds have passed since the first unsent event was logged.
cookieExpirationstring365The number of days after which the Amplitude cookie will expire. 12 months is for GDPR compliance.
cookieNamestringamplitude_idDEPRECATED
sameSiteCookiestring'None'Sets the SameSite flag on the amplitude cookie. Decides cookie privacy policy.
cookieForceUpgradestringfalseForces pre-v6.0.0 instances to adopt post-v6.0.0 compat cookie formats.
deferInitializationstringnullIf true, disables the core functionality of the sdk, including saving a cookie and all logging, until explicitly enabled. To enable tracking, please call amplitude.getInstance().enableTracking() Note: This will not affect users who already have an amplitude cookie. The decision to track events is determined by whether or not a user has an amplitude analytics cookie. If the cookieExpiration</code> is manually defined to be a short lifespan, you may need to run amplitude.getInstance().enableTracking()` upon the cookie expiring or upon logging in.
disableCookiesstringfalseDisable Ampllitude cookies altogether.
deviceIdstringA randomly generated UUID.The custom Device ID to set. Note: This is not recommended unless you know what you are doing (e.g. you have your own system for tracking user devices).
deviceIdFromUrlParamstringfalseIf true, then the SDK will parse Device ID values from the URL parameter amp_device_id if available. Device IDs defined in the configuration options during init will take priority over Device IDs from URL parameters.
domainstringThe top domain of the current page's URL. ('https://amplitude.com')Set a custom domain for the Amplitude cookie. To include subdomains, add a preceding period, eg: .amplitude.com.
eventUploadPeriodMillisstring30000 (30 sec)Amount of time in milliseconds that the SDK waits before uploading events if batchEvents is true.
eventUploadThresholdstring30Minimum number of events to batch together per request if batchEvents is true.
forceHttpsstringtrueIf true, the events will always be uploaded to HTTPS endpoint. Otherwise, it will use the embedding site's protocol.
includeGclidstringfalseIf true, captures the gclid URL parameter as well as the user's initial_gclid via a setOnce operation.
includeReferrerstringfalseIf true, captures the referrer and referring_domain for each session, as well as the user's initial_referrer and initial_referring_domain via a setOnce operation.
includeUtmstringfalseIf true, finds UTM parameters in the query string or the _utmz cookie, parses, and includes them as user properties on all events uploaded. This also captures initial UTM parameters for each session via a setOnce operation.
languagestringThe language determined by the browserCustom language to set.
logLevelstringWARNLevel of logs to be printed in the developer console. Valid values are 'DISABLE', 'ERROR', 'WARN', 'INFO'. To learn more about the different options, see below.
logAttributionCapturedEventstringfalseIf true, the SDK will log an Amplitude event anytime new attribution values are captured from the user. Note: These events count towards your event volume. Event name being logged: [Amplitude] Attribution Captured. Event Properties that can be logged: utm_source, utm_medium, utm_campaign, utm_term, utm_content, referrer, referring_domain, gclid. For UTM properties to be logged, includeUtm must be set to true. For the referrer and referring_domain properties to be logged, includeReferrer must be set to true. For the gclid property to be logged, includeGclid must be set to true.
optOutstringfalseWhether or not to disable tracking for the current user.
onErrorstring() => {}Function to call on error.
platformstringWebiOS
savedMaxCountstring1000Maximum number of events to save in localStorage. If more events are logged while offline, then old events are removed.
saveEventsstringtrueIf true, saves events to localStorage and removes them upon successful upload. Note: Without saving events, events may be lost if the user navigates to another page before the events are uploaded.
saveParamsReferrerOncePerSessionstringtrueIf true, then includeGclid, includeReferrer, and includeUtm will only track their respective properties once per session. New values that come in during the middle of the user's session will be ignored. Set to false to always capture new values.
secureCookiestringfalseIf true, the amplitude cookie will be set with the Secure flag.
sessionTimeoutstring30*60*1000 (30 min)The time between logged events before a new session starts in milliseconds.
trackingOptionsstring{ city: true, country: true, carrier: true, device_manufacturer: true, device_model: true, dma: true, ip_address: true, language: true, os_name: true, os_version: true, platform: true, region: true, version_name: true}Type of data associated with a user.
unsetParamsReferrerOnNewSessionstringfalseIf false, the existing referrer and utm_parameter values will be carried through each new session. If set to true, the referrer and utm_parameter user properties, which include referrer, utm_source, utm_medium, utm_campaign, utm_term, and utm_content, will be set to null upon instantiating a new session. Note: This only works if includeReferrer or includeUtm includeUtm are set to true.
unsentKeystringamplitude_unsentlocalStorage key that stores unsent events.
unsentIdentifyKeystringamplitude_unsent_identifylocalStorage key that stores unsent identifies.
uploadBatchSizestring100The maximum number of events to send to the server per request.