var Pixels = function(core, target, data, returnCB) {
'use strict';
var events = new EventManager(),
template = new Template(),
element = null,
elements = null,
inboundData = null,
data = null,
timeframe = 7,
apiObj = {
'advStats': {
'source': 'actionStats/period/advertisers/' + core.userID + '/-/-/' + timeframe,
'noID': true
},
'advStatsToday': {
'source': 'actionStats/period/advertisers/' + core.userID + '/-/-/0',
'noID': true
},
},
apiManager = new ApiManager(apiObj, core.userID, init);
this.exit = exit;
function getDataTimeframe() {
return {
"data": [{
"title": "Last 7 days",
"value": 7
},
{
"title": "Last 15 days",
"value": 15
},
{
"title": "Last 30 days",
"value": 30
}
],
"options": {
"dropdownClass": "cool",
"menuItemClass": "cool",
"carrotClass": "cool"
}
}
}
function getDataAlerts() {
return {
"title": "Uh Oh! Your pixels have never loaded.",
"message": "In order for us to properly track, retarget, and optimize your advertising campaigns, we need our pixels to be placed on your website. Please download and follow our instructions:",
"highlight": "we need our pixels to be placed on your website."
}
}
function getDataInfo(d) {
return [{
"title": "Loads",
"value": fmtNum(d.views, 1)
},
{
"title": "Avg. daily loads",
"value": fmtNum(d.views / timeframe, 1)
}
]
}
function Data(d) {
this.timeframe = getDataTimeframe();
this.alert = getDataAlerts();
this.info = getDataInfo(d.advStats || {
views: 0
});
this.dailyUsers = (d.advStatsToday && d.advStatsToday.views) ? d.advStatsToday.views : 'None Yet';
// this.lastPixelHit = isString(d.pixelStats.lastPixelHit) ? d.pixelStats.lastPixelHit : 'None Yet';
// this.lastConversion = isString(d.pixelStats.latestPixelConversion) ? d.pixelStats.latestPixelConversion : 'None Yet';
this.requiredPixel = getRequiredPixel(core.brand, core.userID);
this.conversionPixel = getConversionPixel();
this.advancedProductsPixel = getAdvancedProductsPixel();
}
function Template() {
var header = 'Manage Pixels
{{ message }}
'; var requiredPixel = 'Required Pixel:Place this code within your <head> tags on all pages:
Conversion Pixel:Place this code on your conversion pages:
Advanced:Place these codes within the <body> tags on pages of your choice:
Click here to track the products a user is engaging with...{{ title }}:
{{/ info }}Timeframe:
Regular pixel valid as of:
' + // 'Conversion pixel valid as of:
' + 'Users segmented today:
' + '