Large data javascripts collect page data and click Stream to send to Nginx__c language

Source: Internet
Author: User
Tags autoload session id uuid

Large data javascripts collect page data and click Stream to send to nginx---->flume

Page

 



Javascript:

(function () {var cookieutil = {//Get the cookie of the ' key is name Get:function (name) {var cookiename = enc
				Odeuricomponent (name) + "=", Cookiestart = Document.cookie.indexOf (cookiename), cookievalue = null;
					if (Cookiestart >-1) {var cookieend = document.cookie.indexOf (";", Cookiestart);
					if (cookieend = = 1) {cookieend = Document.cookie.length;
				} Cookievalue = decodeURIComponent (document.cookie.substring (Cookiestart+cookiename.length, cookieend));
			return cookievalue; },//Set the Name/value pair to browser cookie set:function (name, value, expires, path, domain, secure) {var

				Cookietext = encodeURIComponent (name) + "=" + encodeuricomponent (value);
					if (expires) {//Set the expires time var expirestime = new Date ();
					Expirestime.settime (expires);
				Cookietext + = "expires=" + expirestime.togmtstring ();
				} if (path) {Cookietext + = ";p ath=" + path; } if (domain{Cookietext + = ";d omain=" + domain;
				} if (secure) {cookietext + = '; secure ';
			} document.cookie = Cookietext;
			}, Setext:function (name, value) {This.set (name, value, new Date (). GetTime () + 315360000000, "/");

	}
	}; The subject, in fact, is tracker js var tracker = {//config ClientConfig: {serverurl: "Http://firstproject/log.gif",//192 .168.184.222 Firstproject Host Configuration sessiontimeout:360,//360s-> 6min maxwaittime:3600,//3600s-> 60min
				-> 1h ver: "1"}, cookieexpirestime:315360000000,//cookie expiration time, 10 columns: {//Send to server column name EventName: "En", Version: "Ver", Platform: "PL", SDK: "SDK", uuid: "U_ud", MemberID: "U_mid", ses Sionid: "U_sd", Clienttime: "C_time", Language: "L", useragent: "B_iev", Resolution: "B_rst", Currentu RL: "P_url", Referrerurl: "P_ref", Title: "tt", OrderId: "OID", Ordername: "On", Currencyamount: "CUA" CUrrencytype: "Cut", Paymenttype: "PT", Category: "Ca", Action: "AC", KV: "Kv_", Duration: "Du"}, Keys: {pageview: "E_PV", Chargerequestevent: "E_crt", Launch: "E_l", Eventdurationevent: "E_e", si D: "Bftrack_sid", uuid: "Bftrack_uuid", Mid: "Bftrack_mid", Previsittime: "Bftrack_previsit",},/
			* * Get session ID/getsid:function () {return cookieutil.get (THIS.KEYS.SID); /** * Save session ID to Cookie/setsid:function (SID) {if (SID) {Cookieutil.setext (this.keys.sid, sid)
				;
			},/** * Gets the UUID, from the cookie/getuuid:function () {return cookieutil.get (THIS.KEYS.UUID); /** * Save UUID to Cookie/setuuid:function (UUID) {if (UUID) {Cookieutil.setext (This.keys.uuid,
				UUID);
			},/** * Get MemberID * * Getmemberid:function () {return cookieutil.get (This.keys.mid); },/** * Set mid */setmemberid:functIon (mid) {if (mid) {Cookieutil.setext (This.keys.mid, mid); }, Startsession:function () {//Load JS is triggered by the method if (This.getsid ()) {//session ID exists, indicating that the UUID also exists if (this.i
					Ssessiontimeout ()) {//session expiration, resulting in a new session this.createnewsession ();
					else {//session does not expire, update last access time This.updateprevisittime (new Date (). GetTime ());
				The else {//session ID does not exist, indicating that the UUID does not exist this.createnewsession ();
			} this.onpageview ();
				}, Onlaunch:function () {//Triggers launch event var launch = {}; Launch[this.columns.eventname] = This.keys.launch; Sets the event name This.setcommoncolumns (launch); Set up public columns This.senddatatoserver (This.parseparam (Launch)); Final sent encoded data}, Onpageview:function () {//Triggers Page view event if (This.precallapi ()) {var time = new Dat
					E (). GetTime ();
					var pageviewevent = {};
					Pageviewevent[this.columns.eventname] = This.keys.pageView; Pageviewevent[this.columns.currenturl] = Window.location.hRef Set Current URL Pageviewevent[this.columns.referrerurl] = document.referrer; Set the URL of the previous page pageviewevent[this.columns.title] = Document.title; Set title This.setcommoncolumns (pageviewevent); Set up public columns This.senddatatoserver (This.parseparam (pageviewevent));
				Finally send the encoded data SS This.updateprevisittime (time); }, Onchargerequest:function (orderId, name, Currencyamount, Currencytype, Paymenttype) {//Trigger order generation event if (
						This.precallapi ()) {if (!orderid | |!currencytype | |!paymenttype) {This.log ("Order ID, currency type, and payment method cannot be empty");
					return;
						} if (typeof (currencyamount) = = "Number") {//The amount must be numeric var time = new Date (). GetTime ();
						var chargerequestevent = {};
						Chargerequestevent[this.columns.eventname] = this.keys.chargeRequestEvent;
						Chargerequestevent[this.columns.orderid] = orderId;
						Chargerequestevent[this.columns.ordername] = name; Chargerequestevent[this.columns.currencyamount] = Currencyamount
						Chargerequestevent[this.columns.currencytype] = Currencytype;
						Chargerequestevent[this.columns.paymenttype] = Paymenttype; This.setcommoncolumns (chargerequestevent); Set up public columns This.senddatatoserver (This.parseparam (chargerequestevent));
					Finally send the encoded data SS This.updateprevisittime (time);
						else {This.log ("Order Amount must be a number");
					return; }}, Oneventduration:function (category, Action, map, duration) {//Triggering event event if (This.precallap
						I ()) {if (category && action) {var time = new Date (). GetTime ();
						var event = {};
						Event[this.columns.eventname] = this.keys.eventDurationEvent;
						Event[this.columns.category] = category;
						Event[this.columns.action] = action;
								if (map) {for (var k in map) {if (k && map[k]) {event[this.columns.kv + K] = map[k];
						}} if (duration) {event[this.columns.duration] = duration; }
						This.setcommoncolumns (event); Set up public columns This.senddatatoserver (This.parseparam (event));
					Finally send the encoded data SS This.updateprevisittime (time);
					else {This.log ("category and action cannot be empty"); }},/** * The method that must be executed before performing an external method * * Precallapi:function () {if (This.issessiontimeout ()) {//AS
				True to indicate the need for a new this.startsession ();
				else {this.updateprevisittime (new Date (). GetTime ());
			return true;
				}, Senddatatoserver:function (data) {///send a datagram to the server, where data is a string of var that = this;
				var i2 = new Image (1,1);//</img> i2.onerror = function () {//Here you can retry the operation};
			I2.SRC = This.clientConfig.serverUrl + "?" + data; /** * Adds a common part to the data sent to the Log collection server/setcommoncolumns:function (data) {data[this.columns.version] = thi
				S.clientconfig.ver;
				Data[this.columns.platform] = "website";
				DATA[THIS.COLUMNS.SDK] = "JS"; Data[this.columns.uuid] = THIS.GEtuuid (); Set User ID Data[this.columns.memberid] = this.getmemberid (); Set member ID Data[this.columns.sessionid] = this.getsid (); Set SID Data[this.columns.clienttime] = new Date (). GetTime (); Set client time data[this.columns.language] = window.navigator.language; Set Browser language data[this.columns.useragent] = window.navigator.userAgent; Set Browser type data[this.columns.resolution] = screen.width + "*" + screen.height;
			 Set Browser Resolution},/** * Create a new member, and determine whether it is the first time to access the page, if yes, to send the launch event. */Createnewsession:function () {var time = new Date (). GetTime ();//get current operation///1. Session Update operation var sid = Thi S.generateid ();
				Produces a session ID This.setsid (SID); This.updateprevisittime (time); Updated last access time//2. The UUID view operation if (!this.getuuid ()) {//UUID does not exist, first creates the UUID, then saves it to the cookie, and finally triggers the launch event var uuid = This.generateid ();
					Product UUID This.setuuid (UUID);
				This.onlaunch (); },/** * parameter encoding return String */parseparam:function (data) {VAR params = ""; for (var e in data) {if (e && data[e]) {params + = encodeURIComponent (e) + "=" + encodeURIComponent (da
					Ta[e]) + "&";
				} if (params) {return params.substring (0, params.length-1);
				else {return params; },/** * generates UUID/generateid:function () {var chars = ' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcde
				Fghijklmnopqrstuvwxyz ';
				var tmpid = [];
				var R;
				TMPID[8] = tmpid[13] = tmpid[18] = tmpid[23] = '-';

				TMPID[14] = ' 4 '; For (i=0 i<36; i++) {if (!tmpid[i]) {r = 0|
						Math.random () *16; Tmpid[i] = chars[(i==19)? (R & 0x3) |
					0X8:R];
			} return Tmpid.join ('); 
			 /** * Determines whether this session is out-of-date and whether the current time and the most recent access time interval is less than this.clientconfig.sessiontimeout<br/> * returns False if it is less than, otherwise returns true.
				*/Issessiontimeout:function () {var time = new Date (). GetTime ();
				var pretime = Cookieutil.get (this.keys.preVisitTime);
		if (pretime) {			The last visit time exists, then the interval judgment return time-pretime > this.clientConfig.sessionTimeout * 1000;
			return true; /** * Update last access time * * Updateprevisittime:function (times) {Cookieutil.setext (This.keys.preVisitTime, Tim
			e);
			},/** * print Log/log:function (msg) {Console.log (msg);

	},
			
	};
		Externally exposed method Name window.__ae__ = {startsession:function () {tracker.startsession ();
		}, Onpageview:function () {Tracker.onpageview (); }, Onchargerequest:function (orderId, name, Currencyamount, Currencytype, Paymenttype) {tracker.onchargerequest (Orde
		RId, Name, Currencyamount, Currencytype, Paymenttype); }, Oneventduration:function (category, Action, map, duration) {tracker.oneventduration (category, action, map, Durati
		ON);
		}, Setmemberid:function (mid) {Tracker.setmemberid (mid);

	}
	}; Auto Load method var autoload = function () {//parameter set var _aelog_ = _aelog_ | | window._aelog_ | |
		[];
		var MemberID = null; For(i=0;i<_aelog_.length;i++)
		{_aelog_[i][0] = = = "MemberID" && (MemberID = _aelog_[i][1));
		}///based on a given MemberID, set MemberID value MemberID && __ae__.setmemberid (MemberID);
	Start session __ae__.startsession ();

	};
AutoLoad (); })();



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.