Skip to content

Commit

Permalink
Merge pull request #1 from wingify/bug-fix-exception-thrown
Browse files Browse the repository at this point in the history
Fix for "Exception thrown" issue
  • Loading branch information
artistictechie committed Dec 1, 2023
2 parents e4d3204 + 74b621e commit 4673778
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
homepage: "https://vwo.com"
documentation: "https://help.vwo.com/hc/en-us/articles/15595250852761-Integrating-VWO-with-Google-Tag-Manager-GTM-"
versions:
- sha: 8ae4c61994fc222336429a81488e362e08ad8a41
changeNotes: Fixes "Exception thrown" issue in the template.
- sha: 264b1b27955c14f79c4f3be12b4203fce3cecda1
changeNotes: Support for default GTM events added.
- sha: 8a0304ad457219a2c6b1d9ac4d0c05b3fdd7c69d
Expand Down
6 changes: 4 additions & 2 deletions template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ ___SANDBOXED_JS_FOR_WEB_TEMPLATE___
const copyFromDataLayer = require("copyFromDataLayer");
const copyFromWindow = require("copyFromWindow");
const createQueue = require("createQueue");
const getType = require("getType");

function isEventNameReserved(eventName) {
const defaultEvents = ["gtm.dom", "gtm.load", "gtm.js"];
Expand Down Expand Up @@ -101,7 +102,7 @@ function isPropertyExcluded(property) {

function findObjectByProperty(array, property, value) {
for (let i = 0; i < array.length; i++) {
if (array[i][property] === value) {
if (array[i] && getType(array[i]) == 'object' && array[i][property] === value) {
return array[i];
}
}
Expand All @@ -116,6 +117,7 @@ function getCurrentEventObject() {
"gtm.uniqueEventId",
eventID
);
if (!object || !object.event) {
return null;
}
Expand Down Expand Up @@ -164,7 +166,7 @@ function buildVwoPayload(obj) {
}

const DLObject = getCurrentEventObject();
if (DLObject) {
if (DLObject != null) {
const VWOPayload = buildVwoPayload(DLObject);
if (VWOPayload) {
const vwoPush = createQueue("VWO");
Expand Down

0 comments on commit 4673778

Please sign in to comment.