How to push data into Google Tag Manager's DataLayer from Wix?

DataLayer.push() allows to pass data to the Data Layer of Google Tag Manager. Is there a way to get data pushed into the Data Layer from Wix code?

Regardless, I saw an option to work with the following package: https://github.com/google/data-layer-helper At first, integration seemed rather simple as there seemed to be a NPM package available https://www.npmjs.com/package/data-layer-helper which I could import in Wix.

However, I tried this, but I can’t seem to figure out which import stament I need to use, as I receive the following error: ModuleNotFoundError: Error loading web module backend/GTM.jsw: Cannot find module ‘data-layer-helper’

My backend GTM.jsw looks as follows:

import * as dlhmodule from ‘data-layer-helper’ ;
// Filename: backend/GTM.jsw (web modules need to have a .jsw extension)

export function getExpFunctions() {
var res = Object.keys(dlhmodule); // List all available functions
return res;
}

After a couple of hours of investigation, I came across a message from the creator of the GitHub repository. He mentioned that there currently is no official NPM package and that someone else published it on npmjs.com.

Therefore, I’m looking for some insights from people who have attempted to work with this library in the past and how they integrated with it. As documentation is really light and I have limited options, any input would help.

I’ve seen a Drupal integration ( https://www.drupal.org/project/datalayer ), so I’d like to achieve the same for Wix. An integration on WP exists as well ( https://wordpress.org/plugins/duracelltomi-google-tag-manager ).

So if anyone has been looking into this or has a shared interest in the integration of GTM in Wix, let me know!

Thanks.

Yves

@Yisrael (Wix) @GOS hope you guys don’t mind me tagging you. Is there anyone at Wix that has deeper knowledge of GTM integration? Mind linking me up?

Use Wix Window’s trackEvent() https://www.wix.com/velo/reference/wix-window/trackevent

All the information sent within the event is made available in the data layer

3 Likes

This indeed seems to be what I was looking for! You saved the day @shan! Thank you very much.

Question: Your link leads to an empty page now, I can only find the function wixWindow.trackEvent but that one seems to only work with Google Analytics but not Tag Manager.
Is there any way to use dataLayer.push to build custom events for Google Tag Manager? I also tried the npm package from OP with the datalayer helper and can’t bring it to work. Thank you

@kachun any response or solution here? I’ve been asked by a client to implement a datalayer push upon a button click event. 3rd party of client is using other analytics outside of google so I’m not sure if wixWindow.trackEvent will work the same

Is there a way to achieve the opposite? for example, pushing a value from Google Tag Manager to Wix?
I have a gtm variable that I have to get into my Wix code.

Did you find an answer? I’m looking for the same purpose. Thanks !

Looks like no one knows or, more likely, this is not possible. Any success with it? I am going to shoot people who decided to go with Wix for our site… :slight_smile:

Hi Everyone, if the objective are found one way to receive data (email, telphone and etc) from the user, i found this way:

Copy the selector ID of the field (of data you want, email, telefone and etc) > Go to Google tag manager > Variables > New Variables > Select DOM Element > Past the selector CSS copied in “Element Selector” > In “atribute name” write “value”.

Like this you can push to Google Tag Manager the email andress or telephone of the user! (Sorry my bad english, i’am just a brazilian guy).

This works for enhanced conversions or another usage. (WITHOUT USING VELO)

like this - Google Ads Enhanced Conversions for Leads - YouTube

Now, if you want the dataLayer for another porpouse, i have bad news for you guys…

FINALY I FOUND!

This include the information inside the dataLayer in GTM

Thank you!! I feel like I’m almost there, it’s just that the selector CSS for my form is really long, and doesn’t look like the one, she had in the video. She mentioned that it might look different, but you should have your developer change it. Did you also have this issue?