From f9ff2eb4b5ab9f126aaa0a71ca8f970633c3f25d Mon Sep 17 00:00:00 2001 From: Mehrdad Date: Fri, 3 May 2024 12:02:27 +0330 Subject: [PATCH] Enhance logging to follow stape conventions Link to convettions: https://github.com/stape-io/gtm-standards/blob/main/standards/GTMS-3.md --- template.js | 14 +++++++++++--- template.tpl | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/template.js b/template.js index d4393f5..4c1c83c 100644 --- a/template.js +++ b/template.js @@ -73,7 +73,16 @@ if (isLoggingEnabled) { if (validateUserData()){ sendConversionToLinkedIn(); } else { - logToConsole('No conversion event was sent to CAPI. You must set 1 out of the 4 acceptable IDs (SHA256_EMAIL, LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID, ACXIOM_ID, ORACLE_MOAT_ID) to resolve this issue or make certain to send both firstName and lastName.'); + if (isLoggingEnabled) { + logToConsole({ + Name: 'LinkedIn', + Type: 'Message', + TraceId: traceId, + EventName: postBody.eventId, + Message: 'No conversion event was sent to LinkedIn CAPI.', + Reason: 'You must set 1 out of the 4 acceptable IDs (SHA256_EMAIL, LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID, ACXIOM_ID, ORACLE_MOAT_ID) to resolve this issue or make certain to send both firstName and lastName.', + }); + } data.gtmOnFailure(); } @@ -83,8 +92,7 @@ function validateUserData() { return true; } - return postBody.user.userInfo.firstName != "" && - postBody.user.userInfo.lastName != ""; + return postBody.user.userInfo.firstName && postBody.user.userInfo.lastName; } diff --git a/template.tpl b/template.tpl index 01943d4..93f2117 100644 --- a/template.tpl +++ b/template.tpl @@ -376,7 +376,16 @@ if (isLoggingEnabled) { if (validateUserData()){ sendConversionToLinkedIn(); } else { - logToConsole('No conversion event was sent to CAPI. You must set 1 out of the 4 acceptable IDs (SHA256_EMAIL, LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID, ACXIOM_ID, ORACLE_MOAT_ID) to resolve this issue or make certain to send both firstName and lastName.'); + if (isLoggingEnabled) { + logToConsole({ + Name: 'LinkedIn', + Type: 'Message', + TraceId: traceId, + EventName: postBody.eventId, + Message: 'No conversion event was sent to LinkedIn CAPI.', + Reason: 'You must set 1 out of the 4 acceptable IDs (SHA256_EMAIL, LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID, ACXIOM_ID, ORACLE_MOAT_ID) to resolve this issue or make certain to send both firstName and lastName.', + }); + } data.gtmOnFailure(); } @@ -386,8 +395,7 @@ function validateUserData() { return true; } - return postBody.user.userInfo.firstName != "" && - postBody.user.userInfo.lastName != ""; + return postBody.user.userInfo.firstName && postBody.user.userInfo.lastName; }