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

Implement option to switch between conversion_async and gtag #20

Merged
merged 7 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 13 additions & 7 deletions src/GoogleAdWordsEventForwarder.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,26 @@
}

// gtag Events
function getBaseGtagEvent(conversionLabel) {
return {
'send-to': gtagSiteId + '/' + conversionLabel,
'value': 0,
'language': 'en',
'remarketing_only': forwarderSettings.remarketingOnly == 'True'
}
}

function generateGtagEvent(mPEvent, conversionLabel, customProps) {
var conversionPayload = {
'send-to': gtagSiteId + '/' + conversionLabel
};
if (!conversionLabel) { return };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should return an explicit null, so that it's not just returning a payload of undefined which looks like it could be a bug.


var conversionPayload = getBaseGtagEvent(conversionLabel);
return mergeObjects(conversionPayload, customProps);
}

function generateGtagCommerceEvent(mPEvent, conversionLabel, customProps) {
var conversionPayload = {
'send-to': gtagSiteId + '/' + conversionLabel
};
if (!conversionLabel) { return };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto to returning null


var customProps = getCustomProps(mPEvent, isPageEvent);
var conversionPayload = getBaseGtagEvent(conversionLabel);

if (mPEvent.ProductAction.ProductActionType === mParticle.ProductActionType.Purchase
&& mPEvent.ProductAction.TransactionId) {
Expand Down
10 changes: 9 additions & 1 deletion test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,11 @@ describe('Adwords forwarder', function () {
'conversion',
{
'send-to': 'AW-123123123/commerceLabel123',
sale: 'seasonal sale'
currency: 'USD',
language: 'en',
remarketing_only: false,
sale: 'seasonal sale',
value: 450
}
];

Expand Down Expand Up @@ -739,8 +743,11 @@ describe('Adwords forwarder', function () {
}
});

// debugger;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove


failMessage.should.not.be.null();
failMessage.should.be.containEql("Can't send to forwarder")
window.dataLayer.length.should.eql(0)
done();
});
});
Expand Down Expand Up @@ -771,6 +778,7 @@ describe('Adwords forwarder', function () {

failMessage.should.not.be.null();
failMessage.should.be.containEql("Can't send to forwarder")
window.dataLayer.length.should.eql(0)
done();
});
});
Expand Down