Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
102f7f09
Commit
102f7f09
authored
Feb 03, 2022
by
Tyler Williams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix currencyCode in enhanced ecommerce events
parent
df3caf52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
app/assets/javascripts/google_tag_manager/index.js
app/assets/javascripts/google_tag_manager/index.js
+6
-5
spec/frontend/google_tag_manager/index_spec.js
spec/frontend/google_tag_manager/index_spec.js
+4
-4
No files found.
app/assets/javascripts/google_tag_manager/index.js
View file @
102f7f09
...
...
@@ -55,16 +55,15 @@ const pushEvent = (event, args = {}) => {
}
};
const
pushEnhancedEcommerceEvent
=
(
event
,
currencyCode
,
args
=
{})
=>
{
const
pushEnhancedEcommerceEvent
=
(
event
,
args
=
{})
=>
{
if
(
!
window
.
dataLayer
)
{
return
;
}
try
{
window
.
dataLayer
.
push
({
ecommerce
:
null
});
window
.
dataLayer
.
push
({
ecommerce
:
null
});
// Clear the previous ecommerce object
window
.
dataLayer
.
push
({
event
,
currencyCode
,
...
args
,
});
}
catch
(
e
)
{
...
...
@@ -189,6 +188,7 @@ export const trackCheckout = (selectedPlan, quantity) => {
const
eventData
=
{
ecommerce
:
{
currencyCode
:
'
USD
'
,
checkout
:
{
actionField
:
{
step
:
1
},
products
:
[
product
],
...
...
@@ -197,7 +197,7 @@ export const trackCheckout = (selectedPlan, quantity) => {
};
// eslint-disable-next-line @gitlab/require-i18n-strings
pushEnhancedEcommerceEvent
(
'
EECCheckout
'
,
'
USD
'
,
eventData
);
pushEnhancedEcommerceEvent
(
'
EECCheckout
'
,
eventData
);
};
export
const
trackTransaction
=
(
transactionDetails
)
=>
{
...
...
@@ -215,6 +215,7 @@ export const trackTransaction = (transactionDetails) => {
const
eventData
=
{
ecommerce
:
{
currencyCode
:
'
USD
'
,
purchase
:
{
actionField
:
{
id
:
transactionId
,
...
...
@@ -228,5 +229,5 @@ export const trackTransaction = (transactionDetails) => {
},
};
pushEnhancedEcommerceEvent
(
'
EECtransactionSuccess
'
,
'
USD
'
,
eventData
);
pushEnhancedEcommerceEvent
(
'
EECtransactionSuccess
'
,
eventData
);
};
spec/frontend/google_tag_manager/index_spec.js
View file @
102f7f09
...
...
@@ -224,8 +224,8 @@ describe('~/google_tag_manager/index', () => {
{
ecommerce
:
null
},
{
event
:
'
EECCheckout
'
,
currencyCode
:
'
USD
'
,
ecommerce
:
{
currencyCode
:
'
USD
'
,
checkout
:
{
actionField
:
{
step
:
1
},
products
:
[
...
...
@@ -254,8 +254,8 @@ describe('~/google_tag_manager/index', () => {
expect
(
spy
).
toHaveBeenCalledWith
({
ecommerce
:
null
});
expect
(
spy
).
toHaveBeenCalledWith
({
event
:
'
EECCheckout
'
,
currencyCode
:
'
USD
'
,
ecommerce
:
{
currencyCode
:
'
USD
'
,
checkout
:
{
actionField
:
{
step
:
1
},
products
:
[
...
...
@@ -291,8 +291,8 @@ describe('~/google_tag_manager/index', () => {
expect
(
spy
).
toHaveBeenCalledWith
({
ecommerce
:
null
});
expect
(
spy
).
toHaveBeenCalledWith
({
event
:
'
EECCheckout
'
,
currencyCode
:
'
USD
'
,
ecommerce
:
{
currencyCode
:
'
USD
'
,
checkout
:
{
actionField
:
{
step
:
1
},
products
:
[
...
...
@@ -347,8 +347,8 @@ describe('~/google_tag_manager/index', () => {
{
ecommerce
:
null
},
{
event
:
'
EECtransactionSuccess
'
,
currencyCode
:
'
USD
'
,
ecommerce
:
{
currencyCode
:
'
USD
'
,
purchase
:
{
actionField
:
{
id
:
'
123
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment