Data statistics method, device and equipment based on front-end burying points and storage medium
By automatically monitoring and building buried point data packets on the front end and reporting them to the server in real time, the problem of inefficient front-end buried point data statistics in the existing technology is solved, and efficient, accurate and real-time data statistics are achieved.
Patent Information
- Application Number
- CN202411553947.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, front-end buried point data statistics have problems such as high labor costs, high maintenance costs, low data accuracy and poor data real-time performance, resulting in low efficiency.
The preset event processor automatically monitors the front-end target events, builds buried point data packets, and uses the preset reporting method to report the data packets to the server to realize automated buried point and real-time data statistics.
It reduces labor costs, improves data accuracy and real-timeness, reduces development and maintenance costs, and improves the efficiency of front-end buried point data statistics.
Smart Images

Figure CN119473781A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a data statistics method, device, equipment and storage medium based on front-end embedding. Background Art
[0002] Front-end tracking data statistics play an important role in product iteration and optimization. Existing technologies usually use manual tracking to collect user behavior data. However, with the continuous iteration and expansion of the project, the existing tracking method has exposed many defects.
[0003] At present, there are some common problems in the existing technology of tracking point in the industry:
[0004] 1. High labor cost: Traditional tracking requires developers to manually insert statistical codes into the code, which is a very time-consuming and cumbersome process. With the continuous iteration of the project, the tracking code needs to be constantly modified and added, which will greatly increase the workload of developers.
[0005] 2. High maintenance cost: Since the tracking code is coupled with the business code, if a tracking point needs to be modified or deleted during the project iteration process, the code needs to be modified manually, which will greatly increase the maintenance cost.
[0006] 3. Low data accuracy: Due to human factors, manual tracking is likely to result in problems such as missed tracking, wrong tracking, and repeated tracking, which will affect the accuracy of the data. At the same time, due to the dispersion of tracking codes, it is difficult to uniformly manage and check the tracking codes, which further affects the accuracy of the data.
[0007] 4. Poor data real-time performance: Traditional tracking requires manual participation. Therefore, after launching a new function or modifying the tracking code, it takes a certain amount of time to take effect, which cannot meet the requirements for data real-time performance.
[0008] In summary, the existing tracking method is affected by human operation, which makes the implementation process of front-end tracking data statistics high in cost, low in data accuracy and poor in real-time performance, resulting in low efficiency of front-end tracking data statistics.
[0009] Therefore, how to improve the efficiency of front-end data statistics has become a technical problem that needs to be solved urgently. Summary of the invention
[0010] The present application provides a data statistics method, device, equipment and storage medium based on front-end buried points, aiming to improve the efficiency of front-end buried point data statistics.
[0011] In a first aspect, the present application provides a data statistics method based on front-end buried points, and the data statistics method based on front-end buried points comprises the following steps:
[0012] Based on the preset event handler, monitor the target events of the front end;
[0013] When the target event meets the preset screening condition, constructing a tracking data package based on the event information of the target event;
[0014] Based on a preset reporting method, the tracking data packet is reported to the server so that the server can perform statistical analysis on the target event.
[0015] In a second aspect, the present application further provides a data statistics device based on front-end buried points, the data statistics device based on front-end buried points comprising:
[0016] The event monitoring module is used to monitor the target events of the front end based on the preset event handler;
[0017] An event tracking module is used to construct a tracking data package based on the event information of the target event when the target event meets the preset screening conditions;
[0018] The data reporting module is used to report the tracking data packet to the server based on a preset reporting method, so that the server can perform statistical analysis on the target event.
[0019] In a third aspect, the present application also provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the data statistics method based on front-end burial points as described above are implemented.
[0020] In a fourth aspect, the present application also provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the data statistics method based on front-end burial points as described above are implemented.
[0021] The present application provides a data statistics method, device, computer equipment and storage medium based on front-end buried points. The method of the present application includes monitoring the target event of the front end based on a preset event processor; when the target event meets the preset screening conditions, building a buried point data packet based on the event information of the target event; based on a preset reporting method, reporting the buried point data packet to the server for the server to perform statistical analysis on the target event. Through the above-mentioned method, the present application automatically monitors the front-end target event through a preset event processor, reducing the workload of manual coding, thereby reducing labor costs. When the target event meets the preset screening conditions, a buried point data packet is automatically constructed, avoiding the problems of missing buried, wrong buried and repeated buried caused by human factors, and improving the accuracy of the data. The preset reporting method ensures that the buried point data can be quickly reported to the server without manual intervention, significantly improving the real-time nature of the data. As a result, the development and maintenance costs of the front-end buried point data statistics are reduced, the speed and accuracy of data processing are improved, and the statistical efficiency of the front-end buried point data is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 A flowchart of a first embodiment of a data statistics method based on front-end tracking provided by the present application;
[0024] Figure 2 A schematic diagram of the SPM position coding structure provided in an embodiment of the present application;
[0025] Figure 3 It is a structural schematic diagram of a first embodiment of a data statistics device based on front-end embedding provided by the present application;
[0026] Figure 4 It is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application.
[0027] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0029] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0030] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0031] Please refer to Figure 1 , Figure 1 A flow chart of the first embodiment of a data statistics method based on front-end tracking provided in this application.
[0032] like Figure 1 As shown, the data statistics method based on front-end embedding includes steps S101 to S103.
[0033] S101, based on the preset event processor, monitoring the target event of the front end;
[0034] In one embodiment, by rewriting the addEventListener method of the EventTarget interface, it is possible to automatically insert custom logic (through a function passed in from the outside) into a specific event (click event) without affecting the original event processing logic and avoiding repeated rewriting of the same element. This is suitable for scenarios such as automated tracking.
[0035] In one embodiment, a class named EventListener can be defined, whose main purpose is to rewrite the global EventTarget.prototype.addEventListener method so as to automatically insert custom logic under specific conditions (for example, the event type is click (click event) and the listener is a function and the calling object is an instance of HTMLElement) without affecting the functionality of the original listener.
[0036] EventTarget is an interface in the Web API that provides a mechanism that allows objects to receive notifications when a specific event occurs. The addEventListener method is part of the EventTarget interface and is used to register an event handler on the target object.
[0037] In Web development, HTMLElement is an interface that represents an HTML element. It is the base interface for all specific HTML element interfaces. HTMLElement provides properties and methods common to all HTML elements, such as ID, class name, HTML content, attribute value, etc.
[0038] Exemplarily, the parameters of the addEventListener method in the EventTarget interface can be defined, including but not limited to the string type representing the target event name (such as "click", "load", etc.), the function called when the target event is triggered on the target object, and the object properties.
[0039] In one embodiment, JavaScript can be used to add event listeners for events that may trigger tracking. You can bind an event handling function (event handler) to a specific DOM element, or use event delegation to listen to events of all child elements on a parent element. In the event handling function, first verify whether the element that triggers the event meets the preset tracking conditions. Generally, you can verify by checking the attributes of event.target, such as className (class name), id, dataset (data attributes), etc.
[0040] This embodiment implements the function of automatically inserting custom logic on specific events (such as click events) by rewriting the addEventListener method of the EventTarget interface, while retaining the integrity of the original event processing logic. The advantage of this method is that it can provide an efficient and flexible implementation method for automated point tracking without interfering with existing code. By defining an EventListener class to rewrite the global EventTarget.prototype.addEventListener method, this solution can automatically trigger the preset point tracking logic when specific conditions are met (for example, the event type is click and the listener is a function and the calling object is an instance of HTMLElement), thereby simplifying the point tracking process and reducing duplicate code.
[0041] Furthermore, based on a preset tracking trigger condition, the target event is verified; when the target event meets the preset tracking trigger condition, an automated tracking operation of the target event is executed.
[0042] In one embodiment, in front-end development, "tracking" usually refers to adding monitoring code to the code to track user behavior, page access and other data. These data can be used to analyze user behavior, optimize user experience or perform performance monitoring. Automated tracking refers to automatically triggering these monitoring operations through code, rather than manually writing each monitoring point. Therefore, the tracking trigger condition can be set in advance, and the tracking operation is executed when the target event on the front end triggers the tracking trigger condition.
[0043] In one embodiment, the trigger conditions for embedding points first need to include the event objects that need to be embedded, such as button clicks, page loading, form submissions and other events, and define specific embedding point trigger conditions for each event, such as specific class names, IDs, and data attributes.
[0044] In one embodiment, the event type, listener type and calling object of the target event are obtained; when the event type is a preset embedding event, the listener type is a function type and the calling object is a target element, it is determined that the target event satisfies the embedding trigger condition.
[0045] In one embodiment, the event type can be obtained through event.type in the event object of the event processing function; the listener type can be determined by checking the event processing function, and if the listener is a function, its type is a function type. The calling object usually refers to the DOM element that triggers the event, which can be obtained through event.target.
[0046] In one embodiment, in the event processing function, check whether the current event meets the preset embedding event type; check whether the event processing function is a function type; check whether the calling object is the target element, which can be achieved by checking the ID, class name or other attributes of the element. If all the above conditions are met, it is determined that the target event meets the embedding trigger condition.
[0047] Furthermore, based on the preset screening condition, the element object of the target event is attribute verified to determine whether the element object is a valid element; when the element object is a valid element, it is determined that the target event meets the preset screening condition.
[0048] In one embodiment, in some cases, the user may not want to respond to the click event of certain specific elements, such as buttons in a pop-up box. At this time, it is necessary to add conditional judgment in the event listener to filter these events.
[0049] For example, if the target element of a click event or its parent element has a specific class name or ID, you can do nothing or prevent the event from propagating further.
[0050] For example, an if statement can be added to the event listener function to implement this conditional judgment. If the condition is not met (i.e., the clicked element is not a valid element), a return statement can be used to exit the function, or event bubbling can be prevented by using event.stopPropagation(), or default behavior can be prevented by using event.preventDefault().
[0051] This embodiment effectively filters out specific element events that do not require a response, such as button clicks in a pop-up box, by adding conditional judgments to the event listener. This strategy not only improves the pertinence and accuracy of data collection and avoids interference from invalid data, but also reduces unnecessary resource consumption and potential interference by preventing further propagation of events or default behavior.
[0052] In one embodiment, based on the preset screening conditions, the element attributes of the element object are checked, wherein the element attributes include a class name, an ID, and data attributes; when the element attributes of the element object do not contain invalid element attributes, the element object is determined to be a valid element.
[0053] In one embodiment, in the processing function, it is first necessary to determine whether the click event comes from a valid element (avoid, for example, clicking on a blank area or some components that do not need to be embedded). This can be achieved by checking the attributes of the event target (event.target) (such as a class name, ID selector, or data attribute data-*).
[0054] It should be noted that in some cases, you may need to filter out click events of specific elements, such as button click events in a pop-up box. This can be achieved by adding conditional judgments in the listener.
[0055] Among them, in JavaScript, event.target is a very important property. It belongs to the event object (event), which is created when the event is triggered and contains detailed information about the event. When an event (such as a click, keyboard key, mouse movement, etc.) occurs on the page, the browser creates an event object and passes it to the event handler function bound to the event. In this event object, the event.target property points to the element that triggered the event.
[0056] For example, if a click event listener is bound to a button on a page, when the user clicks the button, event.target will point to the clicked button element.
[0057] In one embodiment, event.target always points to the original triggering element of the event. During the event bubbling phase, event.target points to the deepest element that triggered the event. During the event capturing phase, event.target also points to the deepest element that triggered the event, but the event bubbles up to the ancestor element to which the listener is attached.
[0058] Generally, you can use event.target to get the element that triggered the event, and then operate on the element as needed, such as modifying its style, attributes, or content. You can also use event.target to check whether the element that triggered the event meets the preset filtering conditions, such as whether it has a specific class name or ID, to decide whether to perform certain operations.
[0059] In a specific embodiment, if the monitored object is a click event, when the event handler monitors the front-end trigger click event, it first checks whether the clicked element has a specific class name that is pre-set to trigger the embedding point. If not, no operation is performed. If the clicked element has a specific class name, it checks whether the clicked element is a button in the pop-up box (for example, the .closest() method can be used to find the nearest ancestor element with the .popup-button class); if it is, no operation is performed; if not, the click event can be considered valid and the corresponding operation is performed.
[0060] This embodiment implements a mechanism for attribute verification of the element object of the target event by adding conditional judgment in the event listener, thereby improving the accuracy and effectiveness of the front-end buried data statistics. By presetting the screening conditions, the system can automatically identify and filter out specific element events that you do not want to respond to, such as button clicks in a pop-up box, to avoid the collection of invalid data. This method not only reduces unnecessary data processing, but also ensures that only valid element events that meet specific conditions are recorded and reported, thereby improving the effectiveness of buried data.
[0061] S102: When the target event meets the preset screening condition, construct a tracking data packet based on the event information of the target event;
[0062] In one embodiment, the event information includes event type, event occurrence time, user ID, element ID, page address URL, etc.
[0063] In one embodiment, a tracking data package containing necessary parameters is constructed based on the clicked element (the event object of the target event) and context information, which usually includes but is not limited to the event type (such as click), occurrence time, user ID (if logged in), element ID (such as ID selector or class name), page URL, etc.
[0064] Among them, the page URL (Uniform Resource Locator) is an address used to identify a resource on the Internet. It is a unique identifier for a specific page in a web page or website. Through this address, the browser can find and load the content of the page.
[0065] Generally, a URL can be composed of a protocol, a domain name, a port number, a path, a query string, and a fragment identifier.
[0066] Among them, Protocol: specifies the protocol used when obtaining resources. The most common ones are http and https, which stand for Hypertext Transfer Protocol and Secure Hypertext Transfer Protocol respectively. Domain Name: The address of a website on the Internet, such as www.example.com. Port Number: An optional part used to specify a specific service port on the server. The default http port is port 80 and the default https port is port 443. Path: Specifies the specific location of the resource on the server, such as / path / to / page.html. Query String: Starts with ?, followed by a series of parameters used to send additional information to the server, such as ? search=query&filter=type. Fragment Identifier: Starts with # and is used to point to a specific part of the page, such as #section1.
[0067] For example, this solution can use tracking data that follows the SPM specification. SPM (Super Position Model) is a data collection specification for tracking user behavior. It tracks the user's specific behavior on the page, such as clicks, exposure, etc., by defining parameters. Figure 2 As shown in the figure, the SPM position code consists of four segments: A, B, C, and D. The SPM position code can be carried in different types of logs such as PV logs, exposure logs, and event logs to record the specific location of user behavior. For example, it can record the location of the page the user browsed from which the user clicked on the previous page, or which location was exposed, or the specific area where the event occurred.
[0068] Generally, A represents a site / business, which is usually recorded in the form of a site code, and can also record the platform, such as iOS, mini-programs, etc. B represents a page, which is used to number the business, and the same corresponding pages on different platforms have the same number. C represents a page block, which is used to divide the page into large areas and number it. D represents a point in a block, which is used to number the location in a small area.
[0069] In this embodiment, with the continuous development of front-end technology, automated tracking has become a trend in front-end data statistics. Compared with traditional tracking, automated tracking has higher work efficiency, lower maintenance cost, higher data accuracy and higher data real-time performance. In this embodiment, the event processing function is rewritten to automatically monitor and filter events, and automatically perform tracking operations, thereby realizing front-end automated tracking. Automated tracking can automatically generate tracking code through tools or frameworks, greatly reducing the workload of developers and improving work efficiency. At the same time, automated tracking can also achieve unified management of tracking code, facilitating later maintenance and optimization. Automated tracking can achieve decoupling of tracking code from business code, so that the modification and maintenance of tracking code will not affect the business code. At the same time, automated tracking can also automatically complete the modification and maintenance of tracking code through tools or frameworks, further reducing maintenance costs. Automated tracking can automatically complete the generation and inspection of tracking code through tools or frameworks, avoiding problems such as missed tracking, wrong tracking and repeated tracking caused by human factors, and improving data accuracy. Automated tracking can realize the real-time generation and deployment of tracking codes, so that after the new function is launched or the tracking code is modified, it can take effect immediately, meeting the requirements for real-time data.
[0070] S103. Based on a preset reporting method, the tracking data packet is reported to a server so that the server can perform statistical analysis on the target event.
[0071] In one embodiment, data reporting is a common requirement in front-end development and is used to collect user behavior data, performance indicators and other information in order to analyze user behavior, optimize product experience and monitor system performance.
[0072] Generally, there are multiple ways to report data, such as Ajax / XHR (XMLHttpRequest), Fetch API, Image Beacon, navigator.sendBeacon(), etc. You can use one data reporting method or a combination of multiple data reporting methods.
[0073] Ajax / XHR (XMLHttpRequest) is an asynchronous communication method that allows exchanging data with the server and updating part of the web page without reloading the entire page. Image Beacon creates a hidden Tag, and set its src attribute to the URL where the backend receives the data, with the data appended to the URL as a query parameter. navigator.sendBeacon() is a browser API that allows sending asynchronous HTTP requests when the page is unloaded.
[0074] Understandably, data reporting is a common requirement in front-end development, which is used to collect user behavior data, performance indicators and other information in order to analyze user behavior, optimize product experience and monitor system performance.
[0075] In one embodiment, in order to avoid blocking the user interface, data should be reported in an asynchronous manner. For example, a data reporting method such as Fetch or XMLHttpRequest can be used to send an HTTP request to a backend server or a third-party data analysis platform.
[0076] For example, Image Beacon (image pixel tracking) can be used to report data. The principle is to dynamically create a hidden The tag, whose src attribute is the URL of the backend receiving data, and the data is attached to the URL as a query parameter. This method is simple and easy to use, has good compatibility, and has no cross-domain restrictions. When choosing a reporting method, factors such as data volume, real-time requirements, compatibility, and project maintenance costs need to be considered.
[0077] In one embodiment, for most scenarios, Ajax or Fetch API is a relatively balanced choice. For situations where data needs to be ensured not to be lost due to page closing, navigator.sendBeacon() or a combination of multiple methods can be considered. At the same time, the implementation of tracking logic can be further simplified by utilizing the features of modern front-end frameworks (such as React's Hooks or Vue's custom instructions).
[0078] This embodiment realizes an efficient and reliable front-end data reporting mechanism by flexibly selecting and combining different data reporting methods. This diversified reporting strategy can not only meet the data collection needs in different scenarios, such as data reporting with high real-time requirements or when the page is unloaded, but also ensure compatibility and stability in different browsers and network environments. In addition, the use of asynchronous reporting can avoid blocking the user interface and improve the user experience. At the same time, the characteristics of modern front-end frameworks can further simplify the implementation of the tracking logic and reduce project maintenance costs. Overall, this solution improves the efficiency and accuracy of data reporting, and provides a solid foundation for subsequent data analysis and product optimization.
[0079] In one embodiment, a data reporting requirement is obtained; based on the data reporting requirement, the preset reporting method is determined; based on the preset reporting method, the buried data packet is asynchronously reported to the server.
[0080] In one embodiment, the purpose of using the data is clarified according to the business needs of the tracking point, such as for user behavior analysis, product optimization or fault diagnosis, so as to determine the front-end event data that needs to be collected, such as user behavior data, page access data and form submission data.
[0081] In one embodiment, a suitable reporting method is selected according to data reporting requirements, for example: Ajax / XHR is suitable for data reporting that requires instant feedback; Image Beacon is suitable for lightweight data reporting; navigator.sendBeacon is suitable for scenarios that ensure that data is not lost due to page closing.
[0082] In addition, you also need to consider factors such as data volume, real-time requirements, compatibility, and project maintenance costs to choose the most appropriate method. Use the appropriate data reporting method to asynchronously send the tracking data packet to the server.
[0083] The present embodiment provides a data statistics method based on front-end buried points. The present application method automatically monitors the front-end target events through a preset event processor, which reduces the workload of manual coding and thus reduces labor costs. When the target event meets the preset screening conditions, the buried point data packet is automatically constructed, avoiding the problems of missed burial, wrong burial and repeated burial due to human factors, and improving the accuracy of the data. The preset reporting method ensures that the buried point data can be quickly reported to the server without manual intervention, which significantly improves the real-time nature of the data. As a result, the development and maintenance costs of the front-end buried point data statistics are reduced, the speed and accuracy of data processing are improved, and the statistical efficiency of the front-end buried point data is improved.
[0084] See also Figure 3 , Figure 3 It is a structural schematic diagram of the first embodiment of a data statistics device based on front-end burial points provided in the present application, and the data statistics device based on front-end burial points is used to execute the aforementioned data statistics method based on front-end burial points.
[0085] like Figure 3 As shown, the data statistics device 200 based on front-end tracking includes: an event monitoring module 201, an event tracking module 202 and a data reporting module 203.
[0086] An event monitoring module 201 is used to monitor target events of the front end based on a preset event processor;
[0087] The event tracking module 202 is used to construct a tracking data package based on the event information of the target event when the target event meets the preset screening condition;
[0088] The data reporting module 203 is used to report the tracking data packet to the server based on a preset reporting method, so that the server can perform statistical analysis on the target event.
[0089] In one embodiment, the data statistics device 200 based on the front-end embedding point further includes an event verification module, including:
[0090] An element verification unit, configured to perform attribute verification on the element object of the target event based on the preset screening condition to determine whether the element object is a valid element;
[0091] The valid element determination unit is used to determine whether the target event meets the preset screening condition when the element object is a valid element.
[0092] In one embodiment, the effective element determination unit includes:
[0093] An element attribute checking subunit, used to check the element attributes of the element object based on the preset screening condition, wherein the element attributes include a class name, an ID and a data attribute;
[0094] The valid element determination subunit is used to determine that the element object is a valid element when the element attributes of the element object do not contain invalid element attributes.
[0095] In one embodiment, the data reporting module 203 includes:
[0096] Demand acquisition unit, used to obtain data reporting requirements;
[0097] A reporting mode determining unit, configured to determine the preset reporting mode based on the data reporting requirement;
[0098] A data reporting unit is used to asynchronously report the buried data packet to the server based on the preset reporting method.
[0099] In one embodiment, the event information includes event type, event occurrence time, user ID, element ID, and page address URL.
[0100] In one embodiment, the data statistics device 200 based on the front-end embedding point further includes a embedding point trigger judgment module, including:
[0101] An event verification unit, used to verify the target event based on a preset tracking trigger condition;
[0102] The tracking operation trigger unit is used to execute the automatic tracking operation of the target event when the target event meets the preset tracking trigger condition.
[0103] In one embodiment, the tracking point trigger judgment module further includes:
[0104] An event data acquisition unit, used to acquire the event type, listener type and calling object of the target event;
[0105] The embedding point trigger judgment unit is used to determine whether the target event meets the embedding point trigger condition when the event type is a preset embedding point event, the listener type is a function type and the calling object is a target element.
[0106] It should be noted that technical personnel in the relevant field can clearly understand that, for the convenience and conciseness of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned data statistics method embodiment based on front-end burial points, and will not be repeated here.
[0107] The apparatus provided in the above embodiment may be implemented in the form of a computer program. The computer program may be Figure 4 Runs on the computer device shown.
[0108] See also Figure 4 , Figure 4 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.
[0109] See also Figure 4 The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
[0110] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any data statistics method based on the front-end embedding point.
[0111] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0112] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any data statistics method based on the front-end embedding point.
[0113] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 4The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0114] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0115] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0116] Based on the preset event handler, monitor the target events of the front end;
[0117] When the target event meets the preset screening condition, constructing a tracking data package based on the event information of the target event;
[0118] Based on a preset reporting method, the tracking data packet is reported to the server so that the server can perform statistical analysis on the target event.
[0119] In one embodiment, before implementing the construction of the embedding data packet based on the event information of the target event when the target event meets the preset screening condition, the processor is further used to implement:
[0120] Based on the preset screening condition, perform attribute verification on the element object of the target event to determine whether the element object is a valid element;
[0121] When the element object is a valid element, it is determined that the target event meets the preset screening condition.
[0122] In one embodiment, when the processor implements the property verification of the element object of the target event based on the preset screening condition to determine whether the element object is a valid element, it is configured to implement:
[0123] Based on the preset screening condition, checking the element attributes of the element object, wherein the element attributes include class name, ID and data attributes;
[0124] When the element attributes of the element object do not include invalid element attributes, the element object is determined to be a valid element.
[0125] In one embodiment, when the processor implements the reporting of the tracking data packet to the server based on the preset reporting method, it is used to implement:
[0126] Obtain data reporting requirements;
[0127] Based on the data reporting requirement, determining the preset reporting method;
[0128] Based on the preset reporting method, the buried data packet is asynchronously reported to the server.
[0129] In one embodiment, the event information includes event type, event occurrence time, user ID, element ID, and page address URL.
[0130] In one embodiment, before implementing the construction of the embedding data packet based on the event information of the target event when the target event meets the preset screening condition, the processor is further used to implement:
[0131] Based on the preset triggering conditions, verify the target event;
[0132] When the target event meets the preset tracking trigger condition, the automatic tracking operation of the target event is executed.
[0133] In one embodiment, before the processor implements the automatic tracking operation of the target event when the target event meets the preset tracking trigger condition, the processor is further used to implement:
[0134] Obtain the event type, listener type and calling object of the target event;
[0135] When the event type is a preset embedding event, the listener type is a function type, and the calling object is a target element, it is determined that the target event satisfies the embedding trigger condition.
[0136] A computer-readable storage medium is also provided in an embodiment of the present application, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any one of the data statistics methods based on front-end burial points provided in the embodiments of the present application.
[0137] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the computer device.
[0138] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A data statistics method based on front-end embedding points, characterized in that: The method comprises: Based on the preset event handler, monitor the target events of the front end; When the target event meets the preset screening condition, constructing a tracking data package based on the event information of the target event; Based on a preset reporting method, the tracking data packet is reported to the server so that the server can perform statistical analysis on the target event.
2. The data statistics method based on front-end embedding points according to claim 1 is characterized in that: When the target event meets the preset screening condition, before constructing the embedding data packet based on the event information of the target event, the method further includes: Based on the preset screening condition, perform attribute verification on the element object of the target event to determine whether the element object is a valid element; When the element object is a valid element, it is determined that the target event meets the preset screening condition.
3. The data statistics method based on front-end embedding points according to claim 2 is characterized in that: The performing attribute verification on the element object of the target event based on the preset screening condition to determine whether the element object is a valid element includes: Based on the preset screening condition, checking the element attributes of the element object, wherein the element attributes include class name, ID and data attributes; When the element attributes of the element object do not include invalid element attributes, the element object is determined to be a valid element.
4. The data statistics method based on front-end embedding points according to claim 1 is characterized in that: The step of reporting the tracking data packet to the server based on a preset reporting method includes: Obtain data reporting requirements; Based on the data reporting requirement, determining the preset reporting method; Based on the preset reporting method, the buried data packet is asynchronously reported to the server.
5. The data statistics method based on front-end embedding points according to claim 1 is characterized in that: The event information includes event type, event occurrence time, user ID, element ID and page address URL.
6. The data statistics method based on front-end embedding points according to claim 1 is characterized in that: When the target event meets the preset screening condition, before constructing the embedding data packet based on the event information of the target event, the method further includes: Based on the preset triggering conditions, verify the target event; When the target event meets the preset tracking trigger condition, the automatic tracking operation of the target event is executed.
7. The data statistics method based on front-end embedding points according to claim 6 is characterized in that: When the target event meets the preset tracking trigger condition, before executing the automatic tracking operation of the target event, the method further includes: Obtain the event type, listener type and calling object of the target event; When the event type is a preset embedding event, the listener type is a function type, and the calling object is a target element, it is determined that the target event satisfies the embedding trigger condition.
8. A data statistics device based on front-end embedding points, characterized in that: The data statistics device based on the front-end buried point includes: The event monitoring module is used to monitor the target events of the front end based on the preset event handler; An event tracking module is used to construct a tracking data package based on the event information of the target event when the target event meets the preset screening conditions; The data reporting module is used to report the tracking data packet to the server based on a preset reporting method, so that the server can perform statistical analysis on the target event.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the data statistics method based on front-end burial points as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the data statistics method based on front-end burial points as described in any one of claims 1 to 7 are implemented.