Summary of the invention
The main purpose of the application is to provide a kind of user behavior data acquisition method and system thereof, to solve being sent request reliably cannot be caused reducing the problem of the accuracy that user behavior data gathers by recording user behavioral data by page JavaScript AJAX mode of prior art existence.
For solving the problems of the technologies described above, according to an aspect of the application, provide a kind of user behavior data acquisition method, it comprises:
Browser control part receives the user behavior data from page script language; The offline queue file that described user behavior data write is preset by described browser control part; Create independent process, and by described independent process, the user behavior data in offline queue file is sent to server.
Wherein, before described browser control part receives the step from the user behavior data of page script language, described method also comprises: user behavior is described as the user behavior data of predetermined structure by described page script language;
The step that described browser control part receives from the user behavior data of page script language comprises: described browser control part is by calling the user behavior data of predetermined structure described in predefined control interface.
Wherein, the user behavior data of described predetermined structure comprises following information: page URL(uniform resource locator), quote source, behavior description, writing time.
Wherein, describedly by described independent process, the step that the user behavior data in offline queue file is sent to server to be comprised: described independent process makes regular check in offline queue file the user behavior data whether having needs to send, if so, then by calling system interface check network state; If network state is idle, then according to first-in first-out, the user behavior data in described offline queue file is sent to described server.
Wherein, described method also comprises: judge whether user behavior data sends successfully, if then these data in described offline queue file deleted.
According to the another aspect of the application, additionally provide a kind of user behavior data acquisition system, it comprises:
Browser control part module, for receiving the user behavior data from page script language, and by offline queue file default for described user behavior data write; Independent process module, for being sent to server by the user behavior data in offline queue file.
Wherein, described browser control part module is by calling the user behavior data of predefined control interface predetermined structure, and wherein, user behavior is described as the user behavior data of predetermined structure by described page script language.
Wherein, the user behavior data of described predetermined structure comprises following information: page URL(uniform resource locator), quote source, behavior description, writing time.
Wherein, described independent process module comprises: data review module, for making regular check in offline queue file whether have user behavior data to be sent; Network state checking module, if for having user behavior data to be sent in offline queue file, then by calling system interface check network state; Data transmission blocks, if be idle for network state, is then sent to described server according to first-in first-out by the user behavior data in offline queue file.
Wherein, described independent process module also comprises: judge module, for judging whether user behavior data sends successfully; These data in described offline queue file if send successfully for user behavior data, are then deleted by removing module.
According to the technical scheme of the application, communicated with browser control part by JavaScript, set up the request transmit queue of off-line, by the user behavior data in independent process transmit queue, namely by JavaScript-browser control part-independent process three collaborative work by the user behavior data reliable diffusion on the page to server, improve the collection accuracy rate of user behavior data.
Embodiment
In one typically configuration, computing equipment comprises one or more processor (CPU), input/output interface, network interface and internal memory.
Internal memory may comprise the volatile memory in computer-readable medium, and the forms such as random access memory (RAM) and/or Nonvolatile memory, as read-only memory (ROM) or flash memory (flash RAM).Internal memory is the example of computer-readable medium.
Computer-readable medium comprises permanent and impermanency, removable and non-removable media can be stored to realize information by any method or technology.Information can be computer-readable instruction, data structure, the module of program or other data.The example of the storage medium of computer comprises, but be not limited to phase transition internal memory (PRAM), static RAM (SRAM), dynamic random access memory (DRAM), the random access memory (RAM) of other types, read-only memory (ROM), Electrically Erasable Read Only Memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tape, tape magnetic rigid disk stores or other magnetic storage apparatus or any other non-transmitting medium, can be used for storing the information can accessed by computing equipment.According to defining herein, computer-readable medium does not comprise non-temporary computer readable media (transitory media), as data-signal and the carrier wave of modulation.
Internal memory may comprise module 1, module 2, module N....
This application provides a kind of user behavior data acquisition method reliably, control interface is called by being changed into from the JavaScript AJAX of prior art by request transmission approach, write local offline queue file, and the mode of transmission is responsible for by independent process, may be there is the unsuccessful problem of transmission in the request of solving, improve the collection success rate of user behavior data.
For making the object of the application, technical scheme and advantage clearly, below in conjunction with drawings and the specific embodiments, the application is described in further detail.
According to the embodiment of the application, provide a kind of user behavior data acquisition method, described data acquisition (Data collecting) refers to process data being sent to server from the client that user uses.
Fig. 1 is the flow chart of the user behavior data acquisition method according to the embodiment of the present application, and as shown in Figure 1, the method comprises:
Step S102, browser control part receives the user behavior data from page script language.
User behavior (User Behavior) is the mode of operation that user uses product, such as, include but not limited to that download file, online game etc. can use the operation of Internet resources in a large number.User behavior is described as the user behavior data of predetermined structure by page script language (JavaScript), browser control part (Plug-in) is by calling the user behavior data of predefined control interface predetermined structure, in actual applications, with reference to figure 2, user behavior data is delivered to browser control part to (KeyValuePair) form in the mode of character string by key-be worth.
Because data collection service has certain demand to transmitted data message, for meeting this data transfer needs, the application defines the composition structure of user behavior data, with reference to figure 3, include but not limited to following information according to the user behavior data of the predetermined structure of the application: page URL(uniform resource locator) (URL), data quote source (guiding the page to come the upper page URL of current location), behavior description information, writing time.Further, require that user behavior data has following characteristics: final generate data volume little (less data once send and have higher success rate), (without the need to additional assemblies Update Table) in config set, be easy to serializing (encoding without the need to complexity when simple data facilitates text to present and sends HTTP request).
Step S104, the offline queue file that user behavior data write is preset by browser control part.
Pre-set the queue file of off-line, the data list in this queue file is according to first in first out (FIFO) mode deal with data.
Step S106, creates independent process, and by independent process, the user behavior data in offline queue file is sent to server.
With reference to figure 4, the browser control part of the application and independent process are cooperated by offline queue (such as disk file), browser control part is responsible for adding user behavior data to lining up afterbody, the data that independent process takes out queue head send, thus the accurate acquisition of completing user behavioral data.
After independent process starts, make regular check in queue file the data whether having and need to send, if had, by the upstate of calling system interface check network, send these data when network idle, after being sent completely, need these data to delete from queue.Describe the handling process of the queue file of independent process in detail below with reference to Fig. 5, in this embodiment, independent process detects in queue file the data having and need to send, and network is in idle condition can send data.With reference to figure 5, this handling process comprises:
Step S502, independent process reads queue file's header data;
Step S504, the data assembling of head is request msg by queue;
Step S506, independent process sends request to server;
Step S508, data are sent completely, and server returns success to independent process, and the conditional code such as returned by HTTP request can judge that whether transmission is successful;
Step S510, independent process deletes the uppermost data of queue file's head;
Step S512, data have been deleted, and continue to continue to perform step S502 when performing step S502 or wait for that next time, detection time arrived.
The application is by communicating with browser control part, set up the request transmit queue of off-line, and the data be responsible for by the independent process independent of browser in transmit queue, namely pass through JavaScript-control-independent process three collaborative work by the user behavior data reliable diffusion on the page to server, thus improve the collection accuracy rate of user behavior data.
According to the embodiment of the application, additionally provide a kind of user behavior data acquisition system, with reference to figure 6, described system at least comprises: browser control part module 610 and independent process module 620, is described below in detail the 26S Proteasome Structure and Function of above-mentioned each module.
Described user behavior data for receiving the user behavior data from page script language, and is write the offline queue file preset by browser control part module 610.In the embodiment of the present application, user behavior is described as the user behavior data of predetermined structure by page script language, wherein, the user behavior data of predetermined structure includes but not limited to following information: page URL(uniform resource locator), quote source, behavior description, writing time.Browser control part module 610 is by calling the user behavior data of predefined control interface predetermined structure.
Independent process module 620 is for being sent to server by the user behavior data in offline queue file.
According to above-described embodiment of the application, by JavaScript-browser control part-independent process three collaborative work by the user behavior data reliable diffusion on the page to server.
With reference to figure 7, independent process module 620 comprises further: data review module 710, network state checking module 720 and data transmission blocks 730.
Wherein, data review module 710, for making regular check in offline queue file whether have user behavior data to be sent;
Network state checking module 720 couples mutually with data review module 710, if for having user behavior data to be sent in offline queue file, then by calling system interface check network state;
Data transmission blocks 730 couples mutually with network state checking module 720, if be idle for network state, then according to first-in first-out, the user behavior data in offline queue file is sent to server.
Continue with reference to figure 7, described independent process module 620 also comprises:
Judge module 740 couples mutually with data transmission blocks 730, for judging whether user behavior data sends successfully;
Removing module 750 couples mutually with judge module 740, if send successfully for user behavior data, then these data in offline queue file is deleted.
The operating procedure of the method for the application is corresponding with the architectural feature of system, can be cross-referenced, repeats no longer one by one.
In sum, according to the technique scheme of the application, communicated with browser control part by JavaScript, set up the request transmit queue of off-line, by the user behavior data in independent process transmit queue, namely by JavaScript-browser control part-independent process three collaborative work by the user behavior data reliable diffusion on the page to server, improve the collection accuracy rate of user behavior data.
The foregoing is only the embodiment of the application, be not limited to the application, for a person skilled in the art, the application can have various modifications and variations.Within all spirit in the application and principle, any amendment done, equivalent replacement, improvement etc., within the right that all should be included in the application.
Those skilled in the art should understand, the embodiment of the application can be provided as method, system or computer program.Therefore, the application can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the application can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disc store, CD-ROM, optical memory etc.) of computer usable program code.