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

#977 Send user's phone to CarrotQuest service #979

Merged
merged 4 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion front/js/components/orderCall.es6
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
server.sendOrderCall(phone, time, url)
.then(() => {
DOM.$timeText.text(DOM.$timeTag.val());
mediator.publish('onBackCallSend');
mediator.publish('onBackCallSend', phone);
});
}

Expand Down
5 changes: 3 additions & 2 deletions front/js/components/product.es6
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@
helpers.setDisabledState(DOM.$oneClick, 'Ожидайте...');
const { id, quantity } = getProductData();

server.oneClickBuy(id, quantity, DOM.$phone.val())
const phone = DOM.$phone.val();
server.oneClickBuy(id, quantity, phone)
.then(() => {
mediator.publish('onOneClickBuy');
mediator.publish('onOneClickBuy', phone);
// Set timeout to wait handling of onOneClickBuy
setTimeout(() => {
window.location.href = configs.hrefs.orderSuccess;
Expand Down
2 changes: 1 addition & 1 deletion front/js/shared/mediator.es6
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* We implements mediator pattern via jQuery's global events
* We implement mediator pattern via jQuery's global events
* on empty object (it could be a window or a documents, also)
*/
const mediator = {
Expand Down
13 changes: 11 additions & 2 deletions front/js/shared/tracking.es6
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@
};

function setUpListeners() {
mediator.subscribe('onOneClickBuy', () => {
mediator.subscribe('onOneClickBuy', (_, phone) => {
reachGoal('CMN_BUY_SEND');
reachGoal('FAST_BUY_SEND');
// @todo #977:120m Create some lazy() wrapper for counters.
// `lazy(my_counter).reachGoal()` should asynchronous delay reaching
Copy link
Contributor

Choose a reason for hiding this comment

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

That GA loader could be helpful as a reference implementation

// until my_counter object won't be fully loaded.
// See our custom the Google Analytics code as reference implementation:
// https://github.com/fidals/refarm-site/pull/314/files
carrotquest.identify({ $phone: phone }); // Ignore ESLintBear (no-undef)
});
mediator.subscribe('onOrderSend', () => {
reachGoal('CMN_BUY_SEND');
Expand All @@ -52,7 +58,10 @@
yaTracker.remove([data]);
});
mediator.subscribe('onProductDetail', (_, data) => yaTracker.detail([data]));
mediator.subscribe('onBackCallSend', () => reachGoal('BACK_CALL_SEND'));
mediator.subscribe('onBackCallSend', (_, phone) => {
reachGoal('BACK_CALL_SEND');
carrotquest.identify({ $phone: phone }); // Ignore ESLintBear (no-undef)
});
mediator.subscribe('onSuccessOrder', (_, orderPositions, orderData) => {
yaTracker.purchase(orderPositions, orderData);
gaTracker.purchase(orderPositions, orderData);
Expand Down
14 changes: 14 additions & 0 deletions templates/layout/google_tag_manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@
goals: goals,
}
}());

var carrotquest = (function() {
var data_ = [];

var identify = function(data) {
data_.push(data);
console.log(data);
};

return {
identify: identify,
data: data_,
}
}());
</script>
{% endif %}
{% endif %}