analytics-public.d.ts 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. /**
  2. * Firebase Analytics
  3. *
  4. * @packageDocumentation
  5. */
  6. import { FirebaseApp } from '@firebase/app';
  7. /**
  8. * An instance of Firebase Analytics.
  9. * @public
  10. */
  11. export declare interface Analytics {
  12. /**
  13. * The {@link @firebase/app#FirebaseApp} this {@link Analytics} instance is associated with.
  14. */
  15. app: FirebaseApp;
  16. }
  17. /**
  18. * Additional options that can be passed to Analytics method
  19. * calls such as `logEvent`, etc.
  20. * @public
  21. */
  22. export declare interface AnalyticsCallOptions {
  23. /**
  24. * If true, this config or event call applies globally to all
  25. * Google Analytics properties on the page.
  26. */
  27. global: boolean;
  28. }
  29. /**
  30. * {@link Analytics} instance initialization options.
  31. * @public
  32. */
  33. export declare interface AnalyticsSettings {
  34. /**
  35. * Params to be passed in the initial `gtag` config call during Firebase
  36. * Analytics initialization.
  37. */
  38. config?: GtagConfigParams | EventParams;
  39. }
  40. /**
  41. * Consent status settings for each consent type.
  42. * For more information, see
  43. * {@link https://developers.google.com/tag-platform/tag-manager/templates/consent-apis
  44. * | the GA4 reference documentation for consent state and consent types}.
  45. * @public
  46. */
  47. export declare interface ConsentSettings {
  48. /** Enables storage, such as cookies, related to advertising */
  49. ad_storage?: ConsentStatusString;
  50. /** Enables storage, such as cookies, related to analytics (for example, visit duration) */
  51. analytics_storage?: ConsentStatusString;
  52. /**
  53. * Enables storage that supports the functionality of the website or app such as language settings
  54. */
  55. functionality_storage?: ConsentStatusString;
  56. /** Enables storage related to personalization such as video recommendations */
  57. personalization_storage?: ConsentStatusString;
  58. /**
  59. * Enables storage related to security such as authentication functionality, fraud prevention,
  60. * and other user protection.
  61. */
  62. security_storage?: ConsentStatusString;
  63. [key: string]: unknown;
  64. }
  65. /**
  66. * Whether a particular consent type has been granted or denied.
  67. * @public
  68. */
  69. export declare type ConsentStatusString = 'granted' | 'denied';
  70. /**
  71. * Standard `gtag.js` control parameters.
  72. * For more information, see
  73. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  74. * | the GA4 reference documentation}.
  75. * @public
  76. */
  77. export declare interface ControlParams {
  78. groups?: string | string[];
  79. send_to?: string | string[];
  80. event_callback?: () => void;
  81. event_timeout?: number;
  82. }
  83. /**
  84. * Standard Google Analytics currency type.
  85. * @public
  86. */
  87. export declare type Currency = string | number;
  88. /**
  89. * Any custom event name string not in the standard list of recommended
  90. * event names.
  91. * @public
  92. */
  93. export declare type CustomEventName<T> = T extends EventNameString ? never : T;
  94. /**
  95. * Any custom params the user may pass to `gtag`.
  96. * @public
  97. */
  98. export declare interface CustomParams {
  99. [key: string]: unknown;
  100. }
  101. /**
  102. * Type for standard Google Analytics event names. `logEvent` also accepts any
  103. * custom string and interprets it as a custom event name.
  104. * @public
  105. */
  106. export declare type EventNameString = 'add_payment_info' | 'add_shipping_info' | 'add_to_cart' | 'add_to_wishlist' | 'begin_checkout' | 'checkout_progress' | 'exception' | 'generate_lead' | 'login' | 'page_view' | 'purchase' | 'refund' | 'remove_from_cart' | 'screen_view' | 'search' | 'select_content' | 'select_item' | 'select_promotion' | 'set_checkout_option' | 'share' | 'sign_up' | 'timing_complete' | 'view_cart' | 'view_item' | 'view_item_list' | 'view_promotion' | 'view_search_results';
  107. /**
  108. * Standard `gtag.js` event parameters.
  109. * For more information, see
  110. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  111. * | the GA4 reference documentation}.
  112. * @public
  113. */
  114. export declare interface EventParams {
  115. checkout_option?: string;
  116. checkout_step?: number;
  117. item_id?: string;
  118. content_type?: string;
  119. coupon?: string;
  120. currency?: string;
  121. description?: string;
  122. fatal?: boolean;
  123. items?: Item[];
  124. method?: string;
  125. number?: string;
  126. promotions?: Promotion[];
  127. screen_name?: string;
  128. /**
  129. * Firebase-specific. Use to log a `screen_name` to Firebase Analytics.
  130. */
  131. firebase_screen?: string;
  132. /**
  133. * Firebase-specific. Use to log a `screen_class` to Firebase Analytics.
  134. */
  135. firebase_screen_class?: string;
  136. search_term?: string;
  137. shipping?: Currency;
  138. tax?: Currency;
  139. transaction_id?: string;
  140. value?: number;
  141. event_label?: string;
  142. event_category?: string;
  143. shipping_tier?: string;
  144. item_list_id?: string;
  145. item_list_name?: string;
  146. promotion_id?: string;
  147. promotion_name?: string;
  148. payment_type?: string;
  149. affiliation?: string;
  150. page_title?: string;
  151. page_location?: string;
  152. page_path?: string;
  153. [key: string]: unknown;
  154. }
  155. /**
  156. * Returns an {@link Analytics} instance for the given app.
  157. *
  158. * @public
  159. *
  160. * @param app - The {@link @firebase/app#FirebaseApp} to use.
  161. */
  162. export declare function getAnalytics(app?: FirebaseApp): Analytics;
  163. /**
  164. * Retrieves a unique Google Analytics identifier for the web client.
  165. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/reference/config#client_id | client_id}.
  166. *
  167. * @public
  168. *
  169. * @param app - The {@link @firebase/app#FirebaseApp} to use.
  170. */
  171. export declare function getGoogleAnalyticsClientId(analyticsInstance: Analytics): Promise<string>;
  172. /**
  173. * A set of common Google Analytics config settings recognized by
  174. * `gtag.js`.
  175. * @public
  176. */
  177. export declare interface GtagConfigParams {
  178. /**
  179. * Whether or not a page view should be sent.
  180. * If set to true (default), a page view is automatically sent upon initialization
  181. * of analytics.
  182. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/page-view | Page views }
  183. */
  184. 'send_page_view'?: boolean;
  185. /**
  186. * The title of the page.
  187. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/page-view | Page views }
  188. */
  189. 'page_title'?: string;
  190. /**
  191. * The URL of the page.
  192. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/page-view | Page views }
  193. */
  194. 'page_location'?: string;
  195. /**
  196. * Defaults to `auto`.
  197. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
  198. */
  199. 'cookie_domain'?: string;
  200. /**
  201. * Defaults to 63072000 (two years, in seconds).
  202. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
  203. */
  204. 'cookie_expires'?: number;
  205. /**
  206. * Defaults to `_ga`.
  207. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
  208. */
  209. 'cookie_prefix'?: string;
  210. /**
  211. * If set to true, will update cookies on each page load.
  212. * Defaults to true.
  213. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
  214. */
  215. 'cookie_update'?: boolean;
  216. /**
  217. * Appends additional flags to the cookie when set.
  218. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
  219. */
  220. 'cookie_flags'?: string;
  221. /**
  222. * If set to false, disables all advertising features with `gtag.js`.
  223. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/display-features | Disable advertising features }
  224. */
  225. 'allow_google_signals'?: boolean;
  226. /**
  227. * If set to false, disables all advertising personalization with `gtag.js`.
  228. * See {@link https://developers.google.com/analytics/devguides/collection/ga4/display-features | Disable advertising features }
  229. */
  230. 'allow_ad_personalization_signals'?: boolean;
  231. [key: string]: unknown;
  232. }
  233. /**
  234. * Returns an {@link Analytics} instance for the given app.
  235. *
  236. * @public
  237. *
  238. * @param app - The {@link @firebase/app#FirebaseApp} to use.
  239. */
  240. export declare function initializeAnalytics(app: FirebaseApp, options?: AnalyticsSettings): Analytics;
  241. /**
  242. * This is a public static method provided to users that wraps four different checks:
  243. *
  244. * 1. Check if it's not a browser extension environment.
  245. * 2. Check if cookies are enabled in current browser.
  246. * 3. Check if IndexedDB is supported by the browser environment.
  247. * 4. Check if the current browser context is valid for using `IndexedDB.open()`.
  248. *
  249. * @public
  250. *
  251. */
  252. export declare function isSupported(): Promise<boolean>;
  253. /**
  254. * Standard Google Analytics `Item` type.
  255. * @public
  256. */
  257. export declare interface Item {
  258. item_id?: string;
  259. item_name?: string;
  260. item_brand?: string;
  261. item_category?: string;
  262. item_category2?: string;
  263. item_category3?: string;
  264. item_category4?: string;
  265. item_category5?: string;
  266. item_variant?: string;
  267. price?: Currency;
  268. quantity?: number;
  269. index?: number;
  270. coupon?: string;
  271. item_list_name?: string;
  272. item_list_id?: string;
  273. discount?: Currency;
  274. affiliation?: string;
  275. creative_name?: string;
  276. creative_slot?: string;
  277. promotion_id?: string;
  278. promotion_name?: string;
  279. location_id?: string;
  280. /** @deprecated Use item_brand instead. */
  281. brand?: string;
  282. /** @deprecated Use item_category instead. */
  283. category?: string;
  284. /** @deprecated Use item_id instead. */
  285. id?: string;
  286. /** @deprecated Use item_name instead. */
  287. name?: string;
  288. }
  289. /**
  290. * Sends a Google Analytics event with given `eventParams`. This method
  291. * automatically associates this logged event with this Firebase web
  292. * app instance on this device.
  293. * @public
  294. * List of recommended event parameters can be found in
  295. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  296. * | the GA4 reference documentation}.
  297. */
  298. export declare function logEvent(analyticsInstance: Analytics, eventName: 'add_payment_info', eventParams?: {
  299. coupon?: EventParams['coupon'];
  300. currency?: EventParams['currency'];
  301. items?: EventParams['items'];
  302. payment_type?: EventParams['payment_type'];
  303. value?: EventParams['value'];
  304. [key: string]: any;
  305. }, options?: AnalyticsCallOptions): void;
  306. /**
  307. * Sends a Google Analytics event with given `eventParams`. This method
  308. * automatically associates this logged event with this Firebase web
  309. * app instance on this device.
  310. * @public
  311. * List of recommended event parameters can be found in
  312. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  313. * | the GA4 reference documentation}.
  314. */
  315. export declare function logEvent(analyticsInstance: Analytics, eventName: 'add_shipping_info', eventParams?: {
  316. coupon?: EventParams['coupon'];
  317. currency?: EventParams['currency'];
  318. items?: EventParams['items'];
  319. shipping_tier?: EventParams['shipping_tier'];
  320. value?: EventParams['value'];
  321. [key: string]: any;
  322. }, options?: AnalyticsCallOptions): void;
  323. /**
  324. * Sends a Google Analytics event with given `eventParams`. This method
  325. * automatically associates this logged event with this Firebase web
  326. * app instance on this device.
  327. * @public
  328. * List of recommended event parameters can be found in
  329. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  330. * | the GA4 reference documentation}.
  331. */
  332. export declare function logEvent(analyticsInstance: Analytics, eventName: 'add_to_cart' | 'add_to_wishlist' | 'remove_from_cart', eventParams?: {
  333. currency?: EventParams['currency'];
  334. value?: EventParams['value'];
  335. items?: EventParams['items'];
  336. [key: string]: any;
  337. }, options?: AnalyticsCallOptions): void;
  338. /**
  339. * Sends a Google Analytics event with given `eventParams`. This method
  340. * automatically associates this logged event with this Firebase web
  341. * app instance on this device.
  342. * @public
  343. * List of recommended event parameters can be found in
  344. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  345. * | the GA4 reference documentation}.
  346. */
  347. export declare function logEvent(analyticsInstance: Analytics, eventName: 'begin_checkout', eventParams?: {
  348. currency?: EventParams['currency'];
  349. coupon?: EventParams['coupon'];
  350. value?: EventParams['value'];
  351. items?: EventParams['items'];
  352. [key: string]: any;
  353. }, options?: AnalyticsCallOptions): void;
  354. /**
  355. * Sends a Google Analytics event with given `eventParams`. This method
  356. * automatically associates this logged event with this Firebase web
  357. * app instance on this device.
  358. * @public
  359. * List of recommended event parameters can be found in
  360. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  361. * | the GA4 reference documentation}.
  362. */
  363. export declare function logEvent(analyticsInstance: Analytics, eventName: 'checkout_progress', eventParams?: {
  364. currency?: EventParams['currency'];
  365. coupon?: EventParams['coupon'];
  366. value?: EventParams['value'];
  367. items?: EventParams['items'];
  368. checkout_step?: EventParams['checkout_step'];
  369. checkout_option?: EventParams['checkout_option'];
  370. [key: string]: any;
  371. }, options?: AnalyticsCallOptions): void;
  372. /**
  373. * Sends a Google Analytics event with given `eventParams`. This method
  374. * automatically associates this logged event with this Firebase web
  375. * app instance on this device.
  376. * @public
  377. * See
  378. * {@link https://developers.google.com/analytics/devguides/collection/ga4/exceptions
  379. * | Measure exceptions}.
  380. */
  381. export declare function logEvent(analyticsInstance: Analytics, eventName: 'exception', eventParams?: {
  382. description?: EventParams['description'];
  383. fatal?: EventParams['fatal'];
  384. [key: string]: any;
  385. }, options?: AnalyticsCallOptions): void;
  386. /**
  387. * Sends a Google Analytics event with given `eventParams`. This method
  388. * automatically associates this logged event with this Firebase web
  389. * app instance on this device.
  390. * @public
  391. * List of recommended event parameters can be found in
  392. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  393. * | the GA4 reference documentation}.
  394. */
  395. export declare function logEvent(analyticsInstance: Analytics, eventName: 'generate_lead', eventParams?: {
  396. value?: EventParams['value'];
  397. currency?: EventParams['currency'];
  398. [key: string]: any;
  399. }, options?: AnalyticsCallOptions): void;
  400. /**
  401. * Sends a Google Analytics event with given `eventParams`. This method
  402. * automatically associates this logged event with this Firebase web
  403. * app instance on this device.
  404. * @public
  405. * List of recommended event parameters can be found in
  406. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  407. * | the GA4 reference documentation}.
  408. */
  409. export declare function logEvent(analyticsInstance: Analytics, eventName: 'login', eventParams?: {
  410. method?: EventParams['method'];
  411. [key: string]: any;
  412. }, options?: AnalyticsCallOptions): void;
  413. /**
  414. * Sends a Google Analytics event with given `eventParams`. This method
  415. * automatically associates this logged event with this Firebase web
  416. * app instance on this device.
  417. * @public
  418. * See
  419. * {@link https://developers.google.com/analytics/devguides/collection/ga4/page-view
  420. * | Page views}.
  421. */
  422. export declare function logEvent(analyticsInstance: Analytics, eventName: 'page_view', eventParams?: {
  423. page_title?: string;
  424. page_location?: string;
  425. page_path?: string;
  426. [key: string]: any;
  427. }, options?: AnalyticsCallOptions): void;
  428. /**
  429. * Sends a Google Analytics event with given `eventParams`. This method
  430. * automatically associates this logged event with this Firebase web
  431. * app instance on this device.
  432. * @public
  433. * List of recommended event parameters can be found in
  434. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  435. * | the GA4 reference documentation}.
  436. */
  437. export declare function logEvent(analyticsInstance: Analytics, eventName: 'purchase' | 'refund', eventParams?: {
  438. value?: EventParams['value'];
  439. currency?: EventParams['currency'];
  440. transaction_id: EventParams['transaction_id'];
  441. tax?: EventParams['tax'];
  442. shipping?: EventParams['shipping'];
  443. items?: EventParams['items'];
  444. coupon?: EventParams['coupon'];
  445. affiliation?: EventParams['affiliation'];
  446. [key: string]: any;
  447. }, options?: AnalyticsCallOptions): void;
  448. /**
  449. * Sends a Google Analytics event with given `eventParams`. This method
  450. * automatically associates this logged event with this Firebase web
  451. * app instance on this device.
  452. * @public
  453. * See {@link https://firebase.google.com/docs/analytics/screenviews
  454. * | Track Screenviews}.
  455. */
  456. export declare function logEvent(analyticsInstance: Analytics, eventName: 'screen_view', eventParams?: {
  457. firebase_screen: EventParams['firebase_screen'];
  458. firebase_screen_class: EventParams['firebase_screen_class'];
  459. [key: string]: any;
  460. }, options?: AnalyticsCallOptions): void;
  461. /**
  462. * Sends a Google Analytics event with given `eventParams`. This method
  463. * automatically associates this logged event with this Firebase web
  464. * app instance on this device.
  465. * @public
  466. * List of recommended event parameters can be found in
  467. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  468. * | the GA4 reference documentation}.
  469. */
  470. export declare function logEvent(analyticsInstance: Analytics, eventName: 'search' | 'view_search_results', eventParams?: {
  471. search_term?: EventParams['search_term'];
  472. [key: string]: any;
  473. }, options?: AnalyticsCallOptions): void;
  474. /**
  475. * Sends a Google Analytics event with given `eventParams`. This method
  476. * automatically associates this logged event with this Firebase web
  477. * app instance on this device.
  478. * @public
  479. * List of recommended event parameters can be found in
  480. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  481. * | the GA4 reference documentation}.
  482. */
  483. export declare function logEvent(analyticsInstance: Analytics, eventName: 'select_content', eventParams?: {
  484. content_type?: EventParams['content_type'];
  485. item_id?: EventParams['item_id'];
  486. [key: string]: any;
  487. }, options?: AnalyticsCallOptions): void;
  488. /**
  489. * Sends a Google Analytics event with given `eventParams`. This method
  490. * automatically associates this logged event with this Firebase web
  491. * app instance on this device.
  492. * @public
  493. * List of recommended event parameters can be found in
  494. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  495. * | the GA4 reference documentation}.
  496. */
  497. export declare function logEvent(analyticsInstance: Analytics, eventName: 'select_item', eventParams?: {
  498. items?: EventParams['items'];
  499. item_list_name?: EventParams['item_list_name'];
  500. item_list_id?: EventParams['item_list_id'];
  501. [key: string]: any;
  502. }, options?: AnalyticsCallOptions): void;
  503. /**
  504. * Sends a Google Analytics event with given `eventParams`. This method
  505. * automatically associates this logged event with this Firebase web
  506. * app instance on this device.
  507. * @public
  508. * List of recommended event parameters can be found in
  509. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  510. * | the GA4 reference documentation}.
  511. */
  512. export declare function logEvent(analyticsInstance: Analytics, eventName: 'select_promotion' | 'view_promotion', eventParams?: {
  513. items?: EventParams['items'];
  514. promotion_id?: EventParams['promotion_id'];
  515. promotion_name?: EventParams['promotion_name'];
  516. [key: string]: any;
  517. }, options?: AnalyticsCallOptions): void;
  518. /**
  519. * Sends a Google Analytics event with given `eventParams`. This method
  520. * automatically associates this logged event with this Firebase web
  521. * app instance on this device.
  522. * @public
  523. * List of recommended event parameters can be found in
  524. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  525. * | the GA4 reference documentation}.
  526. */
  527. export declare function logEvent(analyticsInstance: Analytics, eventName: 'set_checkout_option', eventParams?: {
  528. checkout_step?: EventParams['checkout_step'];
  529. checkout_option?: EventParams['checkout_option'];
  530. [key: string]: any;
  531. }, options?: AnalyticsCallOptions): void;
  532. /**
  533. * Sends a Google Analytics event with given `eventParams`. This method
  534. * automatically associates this logged event with this Firebase web
  535. * app instance on this device.
  536. * @public
  537. * List of recommended event parameters can be found in
  538. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  539. * | the GA4 reference documentation}.
  540. */
  541. export declare function logEvent(analyticsInstance: Analytics, eventName: 'share', eventParams?: {
  542. method?: EventParams['method'];
  543. content_type?: EventParams['content_type'];
  544. item_id?: EventParams['item_id'];
  545. [key: string]: any;
  546. }, options?: AnalyticsCallOptions): void;
  547. /**
  548. * Sends a Google Analytics event with given `eventParams`. This method
  549. * automatically associates this logged event with this Firebase web
  550. * app instance on this device.
  551. * @public
  552. * List of recommended event parameters can be found in
  553. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  554. * | the GA4 reference documentation}.
  555. */
  556. export declare function logEvent(analyticsInstance: Analytics, eventName: 'sign_up', eventParams?: {
  557. method?: EventParams['method'];
  558. [key: string]: any;
  559. }, options?: AnalyticsCallOptions): void;
  560. /**
  561. * Sends a Google Analytics event with given `eventParams`. This method
  562. * automatically associates this logged event with this Firebase web
  563. * app instance on this device.
  564. * @public
  565. * List of recommended event parameters can be found in
  566. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  567. * | the GA4 reference documentation}.
  568. */
  569. export declare function logEvent(analyticsInstance: Analytics, eventName: 'timing_complete', eventParams?: {
  570. name: string;
  571. value: number;
  572. event_category?: string;
  573. event_label?: string;
  574. [key: string]: any;
  575. }, options?: AnalyticsCallOptions): void;
  576. /**
  577. * Sends a Google Analytics event with given `eventParams`. This method
  578. * automatically associates this logged event with this Firebase web
  579. * app instance on this device.
  580. * @public
  581. * List of recommended event parameters can be found in
  582. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  583. * | the GA4 reference documentation}.
  584. */
  585. export declare function logEvent(analyticsInstance: Analytics, eventName: 'view_cart' | 'view_item', eventParams?: {
  586. currency?: EventParams['currency'];
  587. items?: EventParams['items'];
  588. value?: EventParams['value'];
  589. [key: string]: any;
  590. }, options?: AnalyticsCallOptions): void;
  591. /**
  592. * Sends a Google Analytics event with given `eventParams`. This method
  593. * automatically associates this logged event with this Firebase web
  594. * app instance on this device.
  595. * @public
  596. * List of recommended event parameters can be found in
  597. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  598. * | the GA4 reference documentation}.
  599. */
  600. export declare function logEvent(analyticsInstance: Analytics, eventName: 'view_item_list', eventParams?: {
  601. items?: EventParams['items'];
  602. item_list_name?: EventParams['item_list_name'];
  603. item_list_id?: EventParams['item_list_id'];
  604. [key: string]: any;
  605. }, options?: AnalyticsCallOptions): void;
  606. /**
  607. * Sends a Google Analytics event with given `eventParams`. This method
  608. * automatically associates this logged event with this Firebase web
  609. * app instance on this device.
  610. * @public
  611. * List of recommended event parameters can be found in
  612. * {@link https://developers.google.com/gtagjs/reference/ga4-events
  613. * | the GA4 reference documentation}.
  614. */
  615. export declare function logEvent<T extends string>(analyticsInstance: Analytics, eventName: CustomEventName<T>, eventParams?: {
  616. [key: string]: any;
  617. }, options?: AnalyticsCallOptions): void;
  618. /**
  619. * Field previously used by some Google Analytics events.
  620. * @deprecated Use `Item` instead.
  621. * @public
  622. */
  623. export declare interface Promotion {
  624. creative_name?: string;
  625. creative_slot?: string;
  626. id?: string;
  627. name?: string;
  628. }
  629. /**
  630. * Sets whether Google Analytics collection is enabled for this app on this device.
  631. * Sets global `window['ga-disable-analyticsId'] = true;`
  632. *
  633. * @public
  634. *
  635. * @param analyticsInstance - The {@link Analytics} instance.
  636. * @param enabled - If true, enables collection, if false, disables it.
  637. */
  638. export declare function setAnalyticsCollectionEnabled(analyticsInstance: Analytics, enabled: boolean): void;
  639. /**
  640. * Sets the applicable end user consent state for this web app across all gtag references once
  641. * Firebase Analytics is initialized.
  642. *
  643. * Use the {@link ConsentSettings} to specify individual consent type values. By default consent
  644. * types are set to "granted".
  645. * @public
  646. * @param consentSettings - Maps the applicable end user consent state for gtag.js.
  647. */
  648. export declare function setConsent(consentSettings: ConsentSettings): void;
  649. /**
  650. * Use gtag `config` command to set `screen_name`.
  651. *
  652. * @public
  653. *
  654. * @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
  655. * See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
  656. *
  657. * @param analyticsInstance - The {@link Analytics} instance.
  658. * @param screenName - Screen name to set.
  659. */
  660. export declare function setCurrentScreen(analyticsInstance: Analytics, screenName: string, options?: AnalyticsCallOptions): void;
  661. /**
  662. * Adds data that will be set on every event logged from the SDK, including automatic ones.
  663. * With gtag's "set" command, the values passed persist on the current page and are passed with
  664. * all subsequent events.
  665. * @public
  666. * @param customParams - Any custom params the user may pass to gtag.js.
  667. */
  668. export declare function setDefaultEventParameters(customParams: CustomParams): void;
  669. /**
  670. * Configures Firebase Analytics to use custom `gtag` or `dataLayer` names.
  671. * Intended to be used if `gtag.js` script has been installed on
  672. * this page independently of Firebase Analytics, and is using non-default
  673. * names for either the `gtag` function or for `dataLayer`.
  674. * Must be called before calling `getAnalytics()` or it won't
  675. * have any effect.
  676. *
  677. * @public
  678. *
  679. * @param options - Custom gtag and dataLayer names.
  680. */
  681. export declare function settings(options: SettingsOptions): void;
  682. /**
  683. * Specifies custom options for your Firebase Analytics instance.
  684. * You must set these before initializing `firebase.analytics()`.
  685. * @public
  686. */
  687. export declare interface SettingsOptions {
  688. /** Sets custom name for `gtag` function. */
  689. gtagName?: string;
  690. /** Sets custom name for `dataLayer` array used by `gtag.js`. */
  691. dataLayerName?: string;
  692. }
  693. /**
  694. * Use gtag `config` command to set `user_id`.
  695. *
  696. * @public
  697. *
  698. * @param analyticsInstance - The {@link Analytics} instance.
  699. * @param id - User ID to set.
  700. */
  701. export declare function setUserId(analyticsInstance: Analytics, id: string | null, options?: AnalyticsCallOptions): void;
  702. /**
  703. * Use gtag `config` command to set all params specified.
  704. *
  705. * @public
  706. */
  707. export declare function setUserProperties(analyticsInstance: Analytics, properties: CustomParams, options?: AnalyticsCallOptions): void;
  708. export { }