Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom string input to map event name #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 83 additions & 48 deletions template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,53 +73,77 @@ ___TEMPLATE_PARAMETERS___
"displayValue": "Inherit from client"
},
{
"value": "pinterestEventName",
"value": "overrideClient",
"displayValue": "Override client",
"subParams": [
{
"type": "SELECT",
"name": "eventNameStandard",
"macrosInSelect": false,
"selectItems": [
{
"value": "add_to_cart",
"displayValue": "add_to_cart"
},
{
"value": "checkout",
"displayValue": "checkout"
"type": "RADIO",
"name": "eventNameType",
"radioItems": [
{
"value": "standard",
"displayValue": "Standard event name",
"subParams": [
{
"type": "SELECT",
"name": "eventNameStandard",
"macrosInSelect": false,
"selectItems": [
{
"value": "add_to_cart",
"displayValue": "add_to_cart"
},
{
"value": "checkout",
"displayValue": "checkout"
},
{
"value": "custom",
"displayValue": "custom"
},
{
"value": "lead",
"displayValue": "lead"
},
{
"value": "page_visit",
"displayValue": "page_visit"
},
{
"value": "search",
"displayValue": "search"
},
{
"value": "signup",
"displayValue": "signup"
},
{
"value": "view_category",
"displayValue": "view_category"
},
{
"value": "watch_video",
"displayValue": "watch_video"
}
],
"simpleValueType": true,
"defaultValue": "page_visit"
}
]
},
{
"value": "custom",
"displayValue": "custom"
},
{
"value": "lead",
"displayValue": "lead"
},
{
"value": "page_visit",
"displayValue": "page_visit"
},
{
"value": "search",
"displayValue": "search"
},
{
"value": "signup",
"displayValue": "signup"
},
{
"value": "view_category",
"displayValue": "view_category"
},
{
"value": "watch_video",
"displayValue": "watch_video"
"displayValue": "Custom event name",
"subParams": [
{
"type": "TEXT",
"name": "eventNameCustom",
"simpleValueType": true
}
]
}
],
"simpleValueType": true,
"defaultValue": "page_visit"
}
]
}
Expand Down Expand Up @@ -603,8 +627,10 @@ function getPinterestEventName(gtmEventName, toLowerCase) {
gtmEventName = gtmEventName.trim().toLowerCase();
}
pinterestEventName = EVENT_NAME_MAPPINGS[gtmEventName] || gtmEventName;
} else if ( data.eventName === 'pinterestEventName') {
} else if (data.eventNameType === 'standard') {
pinterestEventName = data.eventNameStandard;
} else if (data.eventNameType === 'custom') {
pinterestEventName = data.eventNameCustom;
}
return pinterestEventName;
}
Expand Down Expand Up @@ -1481,15 +1507,17 @@ ___SERVER_PERMISSIONS___
___TESTS___

scenarios:
- name: On EventModel model data tag triggers to send to Pinterest Conversions API (cAPI)
- name: On EventModel model data tag triggers to send to Pinterest Conversions API
(cAPI)
code: |-
// Act
runCode(testConfigurationData);

//Assert
assertApi('sendHttpRequest').wasCalledWith(requestEndpoint, actualSuccessCallback, requestHeaderOptions, JSON.stringify(requestData));
assertApi('gtmOnSuccess').wasCalled();
- name: On sending 'action_source' from Client, Tag overrides the preset configuration from server side
- name: On sending 'action_source' from Client, Tag overrides the preset configuration
from server side
code: |-
// Act
mock('getAllEventData', () => {
Expand All @@ -1500,7 +1528,8 @@ scenarios:

//Assert
assertThat(JSON.parse(httpBody).data[0].action_source).isEqualTo(testConfigurationData.serverEventDataList[testConfigurationData.serverEventDataList.map(o => o.name).indexOf('action_source')].value);
- name: On not sending 'action_source' from Client, Tag set 'web' as a default value for cAPI
- name: On not sending 'action_source' from Client, Tag set 'web' as a default value
for cAPI
code: |-
// Act
mock('getAllEventData', () => {
Expand Down Expand Up @@ -1564,7 +1593,8 @@ scenarios:

//Assert
assertThat(JSON.parse(httpBody).data[0].event_name).isEqualTo('any_other_name');
- name: On receiving event data, Tag hashes the 'user_data' fields if they are not already hashed
- name: On receiving event data, Tag hashes the 'user_data' fields if they are not
already hashed
code: |-
// Un-hashed raw email_address from Common Event Schema is hashed before posted to Conversions API.

Expand Down Expand Up @@ -1710,7 +1740,8 @@ scenarios:

//Assert
assertThat(JSON.parse(httpBody).data[0].custom_data.value).isEqualTo("12");
- name: On receiving 'content_ids' with different formats, Tag transforms it to an Array of Strings
- name: On receiving 'content_ids' with different formats, Tag transforms it to an
Array of Strings
code: |-
// Act
mock('getAllEventData', () => {
Expand Down Expand Up @@ -1771,7 +1802,7 @@ scenarios:

//Assert
assertThat(JSON.parse(httpBody).data[0].custom_data.content_ids).isEqualTo(["1","3"]);

// Act
mock('getAllEventData', () => {
inputEventModel.content_ids = " ";
Expand Down Expand Up @@ -1802,7 +1833,8 @@ scenarios:

//Assert
assertThat(JSON.parse(httpBody).data[0].custom_data.content_ids).isUndefined();
- name: On receiving 'contents' with different formats, Tag transforms it to a valid Json object if feasible
- name: On receiving 'contents' with different formats, Tag transforms it to a valid
Json object if feasible
code: |-
// Act
mock('getAllEventData', () => {
Expand Down Expand Up @@ -1938,8 +1970,9 @@ scenarios:

//Assert
assertThat(JSON.parse(httpBody).data[0].custom_data.contents).isEqualTo([{"id":"5","item_price":"0","quantity":2},{"id":"item_01","item_price":"12.5","quantity":3}]);
- name: On receiving 'items' from GA4 event, Tag parses them into 'content_ids', 'contents' and 'num_items' for cAPI
code: |+
- name: On receiving 'items' from GA4 event, Tag parses them into 'content_ids', 'contents'
and 'num_items' for cAPI
code: |
// Act
let items = [
{
Expand Down Expand Up @@ -2156,3 +2189,5 @@ Mirko J. Rodriguez Mallma <[email protected]>

Created on 6/2/2022, 4:47:28 PM
Updated on 06/30/2023, 12:00:00 PM