We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f1d9389 commit aac8479Copy full SHA for aac8479
src/index.ts
@@ -6,7 +6,7 @@ import type {
6
} from '@gtm-support/core';
7
import { GtmSupport as GtmPlugin, loadScript } from '@gtm-support/core';
8
import type { App, Plugin } from 'vue';
9
-import { nextTick } from 'vue';
+import { getCurrentInstance, nextTick } from 'vue';
10
import type {
11
ErrorTypes,
12
NavigationFailure,
@@ -240,5 +240,9 @@ export default _default;
240
* @returns The Vue GTM instance if the it was installed, otherwise `undefined`.
241
*/
242
export function useGtm(): GtmPlugin | undefined {
243
- return gtmPlugin;
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
244
+ return (
245
+ getCurrentInstance()?.appContext?.app?.config?.globalProperties?.$gtm ??
246
+ gtmPlugin
247
+ );
248
}
0 commit comments