Inspired by vk-stat
A package for integrating analytics tools.
When using Universal Analytics with GTM, need set storage:none. Without these settings will not work GA, when you install GTM in iframe.
You need request permissions for statEvents.addMiniApps in miniapps with mini_app_id.
We recommend to use yarn for dependency management:
yarn add @mntm/stats{// [GTM|GA|UA|VK] event category
category: string;// [GTM|GA|UA] event label
label: string;// [VK|GA|UA|YM] screen where event occurred
screen: string;// [VK|AMP] additional parameters
params: Record<string,unknown>;}import{prepareParams,createProviderGTM,createSend}from'@mntm/stats';// Re-assigns all query params, for example, for UTM tags.prepareParams();// Create send functionconstsendStats=createSend([createProviderGTM('GTM-XXXXXXX')]);// Send event to all providerssendStats('launch',{label: 'web_app'});Need for VK Statistics provider:
// See @mntm/painless-bridge for enhanced bridge implementationimportbridgefrom'@vkontakte/vk-bridge';// Early token initializationconsttoken=bridge.send('VKWebAppGetAuthToken',{// Your app_idapp_id: 7415273,scope: ''});// Example of reuseable implementationconstapi=async(method: string,params: Record<string,unknown>)=>{const{ access_token }=awaittoken;constresult=awaitbridge.send('VKWebAppCallAPIMethod',{
method,params: Object.assign({
access_token,v: '5.160'},params);});returnresult;};Development of @mntm/stats happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements.
@mntm/stats is MIT licensed.