Summary of the invention
The main purpose of the application is to provide a kind of user behavior data acquisition method and its system, to solve existing skill
Art is existing by page JavaScript AJAX mode to be sent request and can not reliably record user behavior data and cause to reduce and use
The problem of accuracy of family behavioral data acquisition.
In order to solve the above technical problems, providing a kind of user behavior data acquisition side according to the one aspect of the application
Method comprising:
Browser control part receives the user behavior data from page script language;The browser control part is by the user
Preset offline queue file is written in behavioral data;Independent process is created, and by the independent process by offline queue file
In user behavior data be sent to server.
Wherein, before the step of browser control part is received from the user behavior data of page script language, institute
The method of stating further includes:User behavior is described as the user behavior data of predetermined structure by the page script language;
The browser control part was received from the step of user behavior data of page script language:The browser
The user behavior data that control passes through predetermined structure described in calling control interface predetermined.
Wherein, the user behavior data of the predetermined structure includes following information:Page uniform resource locator, reference come
Source, behavior description, record time.
Wherein, described that user behavior data in offline queue file is sent to by server by the independent process
Step includes:The independent process inspect periodically in offline queue file whether the user behavior data of transmission in need, if so,
Then pass through calling system interface check network state;It, will be described offline according to first-in first-out if network state is the free time
User behavior data in queue file is sent to the server.
Wherein, the method also includes:Judge whether user behavior data sends success, if then by the offline queue
The data in file are deleted.
According to the another aspect of the application, a kind of user behavior data acquisition system is additionally provided comprising:
Browser control part module, for receiving the user behavior data from page script language, and by user's row
Preset offline queue file is written for data;Independent process module, for by the user behavior data in offline queue file
It is sent to server.
Wherein, user's row that the browser control part module passes through calling control interface predetermined structure predetermined
For data, wherein user behavior is described as the user behavior data of predetermined structure by the page script language.
Wherein, the user behavior data of the predetermined structure includes following information:Page uniform resource locator, reference come
Source, behavior description, record time.
Wherein, the independent process module includes:Data review module, for inspect periodically in offline queue file whether
There is user behavior data to be sent;Network state checks module, if for there is user's row to be sent in offline queue file
For data, then pass through calling system interface check network state;Data transmission blocks are pressed if being the free time for network state
The user behavior data in offline queue file is sent to the server according to first-in first-out.
Wherein, the independent process module further includes:Judgment module, for judging whether user behavior data sends into
Function;Removing module deletes the data in the offline queue file if sending successfully for user behavior data
It removes.
It according to the technical solution of the application, is communicated by JavaScript with browser control part, establishes offline request hair
Send queue, by the user behavior data in independent process transmit queue, i.e., by JavaScript- browser control part-independence into
Cheng Sanzhe cooperates the user behavior data reliable diffusion on the page to server, improves the acquisition of user behavior data
Accuracy rate.
Specific embodiment
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include non-temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
Memory may include module 1, module 2, module N....
This application provides a kind of reliable user behavior data acquisition methods, by that transmission approach will be requested from existing skill
The JavaScript AJAX of art is changed to call control interface, local offline queue file is written, and be responsible for transmission by independent process
Mode, solve the problems, such as request there may be send it is unsuccessful, improve the acquisition success rate of user behavior data.
To keep the purposes, technical schemes and advantages of the application clearer, below in conjunction with drawings and the specific embodiments, to this
Application is described in further detail.
According to an embodiment of the present application, a kind of user behavior data acquisition method, the data acquisition are provided(Data
collecting)Refer to the process of that the client for using data from user is sent to server.
Fig. 1 is according to the flow chart of the user behavior data acquisition method of the embodiment of the present application, as shown in Figure 1, this method
Including:
Step S102, browser control part receive the user behavior data from page script language.
User behavior(User Behavior)The mode of operation used the product by the user, for example including but be not limited to download
File, online game etc. can largely use the operation of Internet resources.Page script language(JavaScript)User behavior is retouched
State the user behavior data for predetermined structure, browser control part(Plug-in)By calling control interface predetermined
The user behavior data of predetermined structure, in practical applications, with reference to Fig. 2, user behavior data passes through key-value pair
(KeyValuePair)Form is transmitted to browser control part in a manner of character string.
Since data collection service has certain demand to the data information transmitted, to meet the data transmission need
It asks, the application defines the composed structure of user behavior data, with reference to Fig. 3, according to the user behavior of the predetermined structure of the application
Data include but is not limited to following information:Page uniform resource locator(URL), data reference source(The guidance page is come
A upper page URL for current location), behavior description information, record the time.And, it is desirable that user behavior data has following
Feature:The data volume ultimately generated is small(Less data once sends and has higher success rate), in config set(It is repaired without additional assemblies
Change data), be easy to serialize(Simple data facilitates text when being presented and send upper HTTP request without complicated coding).
Preset offline queue file is written in user behavior data by step S104, browser control part.
Offline queue file is preset, the data list in the queue file is according to first in first out(FIFO)At mode
Manage data.
Step S106 creates independent process, and is sent out the user behavior data in offline queue file by independent process
It send to server.
With reference to Fig. 4, the browser control part and independent process of the application passes through offline queue(Such as disk file)It is assisted
Make, browser control part is responsible for additional user behavior data and is sent out to tail portion, the data that independent process takes out queue head are lined up
It send, to complete the accurate acquisition of user behavior data.
After independent process starting, inspect periodically in queue file whether the data of transmission in need, if there is then passing through tune
The available mode that network is checked with system interface, these data are sent in network idle, are needed after being sent completely by the data
It is deleted from queue.Below with reference to the process flow of the queue file of Fig. 5 detailed description independent process, in this embodiment, solely
The data of vertical process detection transmission in need into queue file, and network is in idle condition can send data.With reference to
Fig. 5, the process flow include:
Step S502, independent process read queue file's header data;
The data assembling on head is request data by step S504, queue;
Step S506, independent process send to server and request;
Step S508, data are sent completely, and server is return success to independent process, such as are returned by HTTP request
The status code returned may determine that whether transmission succeeds;
Step S510, independent process delete the uppermost data in queue file head;
Step S512, data, which are deleted, to be completed, and continues to execute step S502 or next detection time is waited to continue to hold when reaching
Row step S502.
The application establishes offline request transmit queue, and by independently of browser by communicating with browser control part
Independent process is responsible for the data in transmit queue, i.e., is cooperated by JavaScript- control-independent process three by the page
On user behavior data reliable diffusion to server, to improve the acquisition accuracy rate of user behavior data.
According to an embodiment of the present application, a kind of user behavior data acquisition system, with reference to Fig. 6, the system are additionally provided
It includes at least:The structure and function of above-mentioned each module is described below in detail in browser control part module 610 and independent process module 620
Energy.
Browser control part module 610 is for receiving the user behavior data from page script language, and by the user
Preset offline queue file is written in behavioral data.In the embodiment of the present application, user behavior is described as by page script language
The user behavior data of predetermined structure, wherein the user behavior data of predetermined structure includes but is not limited to following information:Page system
One Resource Locator, reference source, behavior description, record time.Browser control part module 610 is by calling control predetermined
The user behavior data of part interface predetermined structure.
Independent process module 620 is used to the user behavior data in offline queue file being sent to server.
According to above-described embodiment of the application, cooperated by JavaScript- browser control part-independent process three
By the user behavior data reliable diffusion on the page to server.
With reference to Fig. 7, independent process module 620 further comprises:Data review module 710, network state check module 720
With data transmission blocks 730.
Wherein, whether data review module 710 have user behavior to be sent for inspecting periodically in offline queue file
Data;
Network state checks that module 720 is coupled with 710 phase of data review module, if pending for having in offline queue file
The user behavior data sent then passes through calling system interface check network state;
Data transmission blocks 730 check the coupling of 720 phase of module with network state, if being the free time for network state, press
The user behavior data in offline queue file is sent to server according to first-in first-out.
With continued reference to Fig. 7, the independent process module 620 further includes:
Judgment module 740 is coupled with 730 phase of data transmission blocks, for judging whether user behavior data sends success;
Removing module 750 is coupled with 740 phase of judgment module, if sending successfully for user behavior data, by offline team
The data in column file are deleted.
The operating procedure of the present processes and the structure feature of system are corresponding, can be cross-referenced, no longer repeat one by one.
In conclusion being communicated by JavaScript with browser control part according to the above-mentioned technical proposal of the application, establish
Offline request transmit queue passes through JavaScript- browser by the user behavior data in independent process transmit queue
Control-independent process three cooperates the user behavior data reliable diffusion on the page to server, improves user's row
For the acquisition accuracy rate of data.
The above description is only an example of the present application, is not intended to limit this application, for those skilled in the art
For member, various changes and changes are possible in this application.Within the spirit and principles of this application, it is made it is any modification,
Equivalent replacement, improvement etc., should be included within the scope of the claims of this application.
It should be understood by those skilled in the art that, embodiments herein can provide as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the application
Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the application, which can be used in one or more,
Usable storage medium(Including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)The computer program of upper implementation produces
The form of product.