Skip to content

Instantly share code, notes, and snippets.

@reiro
Created May 27, 2019 15:35
Show Gist options
  • Save reiro/3b5f374d39fa5a065814a1dab78dc32f to your computer and use it in GitHub Desktop.
Save reiro/3b5f374d39fa5a065814a1dab78dc32f to your computer and use it in GitHub Desktop.
smart tags click behavior
"Smart tag able to track click behaviour. Scenario will be ""Add to cart"" for ecommerce.
1. Scenario 1: for this site https://www.income.com.sg/truecare. user can click on answer to the questions.
And we should able to track the click event.
And when we setup ads that link to this smart tag, we can select which click events, so the ads will be show.
2. When user add to cart, Smart tag able to track the ""add to cart event and capture the product information."
# static views/smart_tags/show.js.erb
# now the script add event listener on load of the page
# when the page is rady it calls ready(fn)
# after document fully loaded we call fn(document);
window.addEventListener('load', function() {
ready(fn);
})
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
fn(document);
} else {
document.addEventListener('DOMContentLoaded', fn(document));
}
}
var fn = function(div) {
if (typeof jsContentWait == 'function') {
jsContentWait();
} else {
var clientData = collectData(div);
track(clientData);
if (typeof popupGrabbing == 'function') {
popupGrabbing();
}
}
}
# We should to control the user's click events on the page.
# For example add event listener for all buttons and links on the page and send events with some additional attribute:
# Lets say 'event_source': 'click' and 'click_element': 'some_button_class'... or something else
# It will encrease the count of events in the database.
# then we should be able to filter events by sources and by elements (button 'Add to cart' or 'purchase' etc)
# And then we should be able to disable/enable this groups of events to generate from pages and show to users
# For example generate all pages and ads for products where users clicks at least on 'Add to cart' button.
# Or I have another way:
# during creation of smart tag we can set the button #id or .class and track only events from users who click on it.
# I think it's not correct reading the task description and I think first part is correct.
@scenzz
Copy link

scenzz commented May 27, 2019

  1. Will need to setup the #id or .class to track only those events.
  2. And able to associate at the ad level to different events. So those UID that has those events will show the ads.
  3. Also, when track event, add to cart event, how to capture product information. And able to show the ads that are associate with these products. For .e.g., when user add to cart, product B, D and E. We should able to show product B, D and E. Need to cater to different scenarios for different ecommerce store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment