Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
1abhishekpandey authored Mar 18, 2021
1 parent 1da3199 commit 36ccc86
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
66 changes: 66 additions & 0 deletions integrations/BingAds/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import logger from "../../utils/logUtil";
import ScriptLoader from "../ScriptLoader";

class BingAds {
constructor(config) {
this.apikey = config.apikey;
}

loadBingadsScript() {
var apikey = this.apikey;
(function(w, d, t, r, u) {
var f, n, i;
w[u] = w[u] || [], f = function() {
var o = {
ti: apikey
};
o.q = w[u], w[u] = new UET(o);
}, n = d.createElement(t), n.src = r, n.async = 1, n.onload = n.onreadystatechange = function() {
var s = this.readyState;
s && s !== "loaded" && s !== "complete" || (f(), n.onload = n.onreadystatechange = null)
}, i = d.getElementsByTagName(t)[0], i.parentNode.insertBefore(n, i)
})(window, document, "script", "https://bat.bing.com/bat.js", "uetq");
}

init() {
logger.debug("===in init BingAds===");
console.log(window);
this.loadBingadsScript();
}

isLoaded() {
logger.debug("in Bingads isLoaded");
return (!!window.uetq && window.uetq.push !== Array.prototype.push);
}

isReady() {
logger.debug("in Bingads isReady");
return !!(window.uetq && window.uetq.push !== Array.prototype.push);
}

/*
Visit here(for details Parameter details): https://help.ads.microsoft.com/#apex/3/en/53056/2
Under: What data does UET collect once I install it on my website?
It conatins info about parameters ea,ec,gc,gv,el
*/

track(rudderElement) {
const typeofcall = rudderElement.message.type;
const properties = rudderElement.message.properties;
var event = {
ea: typeofcall
};
if (properties.category) event.ec = properties.category;
if (properties.currency) event.gc = properties.currency;
if (properties.value) event.gv = properties.value;
if (properties.label) event.el = properties.label;
window.uetq.push(event);
}

page(rudderElement) {
window.uetq.push('pageLoad');
}
}

export { BingAds };
3 changes: 3 additions & 0 deletions integrations/BingAds/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { BingAds } from "./browser";

export default BingAds;

0 comments on commit 36ccc86

Please sign in to comment.