Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by sabanades on 28/09/2016.
- */
- /**
- *
- * Created by jartau on 11/02/16.
- * Updated by cvicente on 17/03/16. (Metod)
- * PAX adaptation by gmartinez, starting:21/03/16. (PAX)
- * Overwrite IVgaCore
- *
- * Tools for register events in google analytics for PAX
- *
- */
- define('Analytics', [
- 'CONFIG',
- 'Model',
- 'core-analytics'
- ], function(CONFIG, model) {
- var PaxGA = function() {
- /** @const */
- var testUA = 'UA-72755841-12';
- var UX_UA = 'UA-72755841-17'; //eventos y funnels
- /** @const */
- var allAppsUA = 'UA-53253680-1';
- /** @const */
- var allLanguagesUA = 'UA-72755841-1';
- /** @const */
- var dictionaryUA = { //pageview -> cliente
- 'de_AT': 'UA-72755841-23',
- 'de_CH': 'UA-72755841-14',
- 'de_DE': 'UA-72755841-3',
- 'en_GB': 'UA-72755841-10',
- 'en_IE': 'UA-72755841-11',
- 'es_ES': 'UA-72755841-2',
- 'fr_CH': 'UA-72755841-16',
- 'fr_BE': 'UA-72755841-20',
- 'fr_FR': 'UA-72755841-8',
- 'gr_GR': 'UA-72755841-19',
- 'it_CH': 'UA-72755841-15',
- 'it_IT': 'UA-72755841-4',
- 'nl_NL': 'UA-72755841-9',
- 'nl_BE': 'UA-72755841-21',
- 'pl_PL': 'UA-72755841-5',
- 'pt_PT': 'UA-72755841-6',
- 'ru_RU': 'UA-72755841-7',
- };
- /** @type {boolean} */
- var initialized = false;
- this.catalgJSON = {};
- this.pueJSON = {};
- this.storesJSON = {};
- this.galleryJSON = {};
- IVgaCore.call(this);
- /*
- * Cosntant names
- *
- * Uses these variables to unify the names of actions, events and pages
- */
- this.pageNames = {
- home : 'Home',
- gallery : 'Gallery',
- doors : 'Doors',
- carrousel : 'Carrousel',
- planner : 'Planner'
- };
- //category
- this.eventCategories = {
- trafficOrigin : '(0) [Traffic origin]',
- startingPage : '(1) [Starting Page]',
- //saveProjectBasicInfo : '(2) [Save Project] Basic Info',
- saveProjectStore : '(2) [Save Project] Store',
- saveProjectWeb : '(2) [Save Project] IKEAweb',
- eCommerce : '(3) [Link to IKEA Shopping List]', //web
- // eCommerceStore : '(3) [Link to IKEA Shopping List] Store', //web
- iSellStore : '(3) [iSell] Store', //coworker
- recoverProjectStore : '(7) [Recover Project] Store',
- recoverProjectWeb : '(7) [Recover Project] IKEAweb',
- PDFweb : '(7) [Print PDF] IKEAweb',
- PDFstore : '(7) [Print PDF] Store',
- // USABILITY
- ux_home : '(10) [Usability] Home',
- ux_gallery : '(10) [Usability] Gallery',
- ux_carousel : '(10) [Usability] Carousel',
- ux_product : '(10) [Usability] Product',
- ux_planner : '(10) [Usability] Planner',
- ux_planner_menu : '(10) [Usability] Planner Menu',
- ux_planner_context : '(10) [Usability] Planner Contextual Menu',
- ux_summary : '(10) [Usability] Summary',
- ux_recoverProj : '(10) [Usability] RecoverProject',
- //BEHAVIOUR
- behaviour_save_project : '(11) [Behaviour] Save Project'
- };
- //action
- this.eventActions = {
- gallery : 'Gallery',
- carousel : 'Carousel',
- product : 'Product',
- planner : 'Planner',
- recover : 'Recover Project',
- /*
- * USABILIDAD
- */
- //common/home buttons
- homeBtn : 'Go to Home',
- galleryBtn : 'Go to Gallery',
- productBtn : 'Go to Doors',
- plannerBtn : 'Go to Planner',
- summaryBtn : 'Go to Summary',
- plannerOk : 'Planner Loaded',
- recoverBtn : 'Recovery Project',
- editProjectBtn : 'Edit Project',
- csvBtn : 'Recovery CSV',
- backHomeBtn : 'Back to Home',
- //gallery/product buttons
- toggleFiltersBtn : 'Toggle filters',
- filtersChecked : 'Filtered by',
- showOneProductInterior : 'Open one door',
- showOneProductDoors : 'Close one door',
- showAllProductInterior : 'Open all doors',
- showAllProductDoors : 'Close all doors',
- //planner
- changeBtn : 'Change/New',
- measuresBtn : 'Toggle Measures',
- changeViewBtn : 'Toggle Plant/Front View',
- zoomBtn : 'Zoom By Uppermenu',
- rotateBtn : 'Rotation By Uppermenu',
- zoomKey : 'Zoom By Keyboard',
- rotateKey : 'Rotation By Keyboard',
- mainTab : 'Change tab',
- insideInteriorsTab : 'Change interiors category',
- allDoors : 'Select all doors',
- allFrames : 'Select all frames',
- filterDoor : 'Filter door material',
- doorSelected : 'Select door material',
- slidingPattern : 'Select sliding pattern',
- internalLight : 'Show internal lighting',
- presetSelected : 'Preset choosed',
- onScrollPlannerMenu : 'Scrolling in Planner Menu',
- //summary
- onScrollSummary : 'Scrolling in Summary',
- printBtn : 'Print',
- isellBtn : 'Get CSV',
- shoppingBtn : 'Go to Shopping List',
- //BEHAVIOUR
- same_frame_int_colour : 'Same frame-interior colour combination?'
- };
- /**
- * Return if the service has been initialized with an init() call.
- *
- * @return {boolean} - Flag initialized
- */
- this.isInitialized = function() {
- return initialized;
- };
- this.getStoreStringFomId = function(){
- var storeCode = model.getStoreCode();
- var store = "";
- if ( storeCode != false ) {
- for ( st in this.storesJSON){
- if ( parseInt(this.storesJSON[st].store_PK) == parseInt(storeCode) ){
- store = this.storesJSON[st].store_name +" ("+this.storesJSON[st].store_PK+")";
- break;
- } else {
- store = undefined;
- }
- }
- } else {
- if ( model.getMode() == 'web' ) {
- store = "web";
- } else {
- store = undefined;
- }
- }
- if ( store == undefined ){
- store = "ErrorStore";
- console.warn("((GOOGLE ANALYTICS: MAY FAIL)) Store '"+storeCode+"' not able in this country, please check the store ID in the URL.");
- }
- return store;
- };
- /*
- * Initialize google analytics configuration for PAX
- */
- this.init = function( langCode, JSONs) {
- initialized = true;
- this.catalgJSON = JSONs[0];
- this.pueJSON = JSONs[1];
- this.storesJSON = JSONs[2];
- this.galleryJSON = JSONs[3];
- var store = this.getStoreStringFomId();
- if (!CONFIG.isProd) {
- //test mode
- this.addUA(testUA);
- } else {
- var ua = '';
- if ( typeof dictionaryUA[langCode] === 'undefined' ){
- ua = testUA;
- } else {
- ua = dictionaryUA[langCode];
- }
- this.addUA([ allAppsUA, allLanguagesUA,ua ]);
- }
- this.setDomain(CONFIG.setDomainUA);
- this.addDimensionValue('1', langCode, dictionaryUA[langCode]);
- this.addDimensionValue('2', store, dictionaryUA[langCode]);
- this.setEnabled(true);
- this.start(false);
- };
- /*
- * EVENTS
- *
- * Specific function for events
- */
- //(0) [Traffic origin]
- this.trafficOrigin = function( mode ){
- var store = this.getStoreStringFomId();
- return this.sendEvent(this.eventCategories.trafficOrigin, mode, store );
- };
- //(1) [Starting Page]
- //recover project form home
- this.homeRecover = function(code,price){
- var store = this.getStoreStringFomId();
- if ( model.getMode() != "web" ) {
- return this.sendEvent(this.eventCategories.recoverProjectStore, store, code, price );
- } else {
- return this.sendEvent(this.eventCategories.recoverProjectWeb, store, code, price );
- }
- };
- //ENV Selected
- this.ENVselected = function(puerta,price){
- var doorName;
- if (puerta['id'] != null)
- doorName = this.getPUEnamefromPUEref(puerta);
- else
- doorName = "open wardrobe";
- return this.sendEvent(this.eventCategories.startingPage, this.eventActions.gallery, doorName, price );
- };
- this.getPUEnamefromPUEref = function(puerta){
- // var pue = pueRef.substring(3,6).replace(/^0+/, '');
- // var mat = pueRef.substring(9,12).replace(/^0+/, '');
- var pue = puerta.id;
- var mat = puerta.mat;
- var ref = this.pueJSON[pue].MAT[mat][0];
- while ( ref.length != 8 ){
- ref = "0"+ref;
- }
- return this.catalgJSON[ref].name + ": " + this.catalgJSON[ref].fin;
- };
- //PRODUCT Selected
- this.PRODUCTselected = function(nomARM){
- var options = this.getARMfromName(nomARM);
- return this.sendEvent(this.eventCategories.startingPage, this.eventActions.product, options[0], options[1] );
- };
- this.getARMfromName = function(nomARM){
- var aux = this.galleryJSON.filter_product.measures;
- for (var medida in aux){
- for (var armario in aux[medida]){
- if ( armario == nomARM ){
- var arm = aux[medida][armario];
- var armario = this.catalgJSON[arm.soft_ref].fin;
- var price = this.catalgJSON[arm.soft_ref].price;
- return [armario,price];
- }
- }
- }
- };
- //Measures setted, go to planner
- this.toPlannerFromMeasures = function(shape){
- //measure = measure.join('-');
- return this.sendEvent(this.eventCategories.startingPage, this.eventActions.planner, shape );
- };
- //(2) [save project] store
- this.saveProject = function( door, price){
- var store = this.getStoreStringFomId();
- if ( model.getMode() == 'web' ){
- return this.sendEvent(this.eventCategories.saveProjectWeb, store, door, price );
- } else {
- return this.sendEvent(this.eventCategories.saveProjectStore, store, door, price );
- }
- };
- //(3) [link to IKEA shopping list]
- //SHOPPING LIST
- this.sendToShoppingList = function( door, price){
- var store = this.getStoreStringFomId();
- return this.sendEvent(this.eventCategories.eCommerce, store, door, price);
- };
- //iSell
- this.iSellCoworker = function( door, price ){
- var store = this.getStoreStringFomId();
- return this.sendEvent(this.eventCategories.iSellStore, store, door, price);
- };
- //(7) [Print PDF]
- this.printPDF = function( code, price ){
- var store = this.getStoreStringFomId();
- if ( model.getMode() == 'web' ){
- return this.sendEvent(this.eventCategories.PDFweb , store, code, price);
- } else {
- return this.sendEvent(this.eventCategories.PDFstore , store, code, price);
- }
- };
- /**
- * USABILITY EVENT TRACKING
- */
- this.uxClick = function(event_category, action_button, status, value){
- status = (typeof status == 'undefined' ? 0 : status);
- value = (typeof value == 'undefined' ? 0 : value);
- return this.sendEvent(this.eventCategories[event_category], this.eventActions[action_button], status, value);
- };
- };
- return new PaxGA();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement