Mapping Configuration-Based Data Tracing Method, Device, Electronic Device, and Storage Medium
By converting the scripting language of the target website into an abstract syntax tree collection, and based on the relationship between the mapping configuration file and the annotation fragment, it automatically matches and combines the replaceable attributes in the preset buried code template to output the entity buried code code, solving the complex and cumbersome problems of buried point operations in the existing technology, and achieving rapid convenience and high reliability of buried points.
Patent Information
- Application Number
- CN202110932533.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-13
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2041-08-13
AI Technical Summary
The existing buried point service system requires a large number of manually added buried points on the web page, resulting in complex and cumbersome operations, large workload and low reliability.
By converting the scripting language of the target website into an abstract syntax tree collection, and based on the relationship between the mapping configuration file and the annotation fragment, it automatically matches and combines the replaceable properties in the preset buried code template to output the entity buried code code.
It realizes rapid and convenient burying points, reduces the workload of manual operation, improves the reliability and flexibility of burying points, and avoids mistakes caused by manual copy and paste.
Smart Images

Figure CN113641345B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of buried point services, and in particular, to a buried point method, device, electronic device, and storage medium based on mapping configuration. Background Art
[0002] Buried point, also known as buried point analysis, is a good way of privately deployed data collection. Currently, the method of obtaining user data by implanting buried points in web pages has been widely used. Due to its good privacy and imperceptible characteristics, relevant buried point codes can be implanted in events that users may trigger to complete targeted data collection.
[0003] Today's buried point service systems can be developed independently or use third-party buried point services. If a large number of buried point operations are required in a web page, buried points need to be manually added in multiple places, which is relatively complex and cumbersome. Summary of the Invention
[0004] The purpose of this application is to provide a buried point method, device, electronic device, and storage medium based on mapping configuration, and realize the rapid and convenient buried point through the mapping relationship between the template configuration file and the annotation segment.
[0005] In a first aspect, an embodiment of this application provides a buried point method based on mapping configuration, and the method includes:
[0006] Convert the script language of the target website into a set of abstract syntax trees, and the set of abstract syntax trees includes multiple abstract syntax tree segments;
[0007] Obtain the target key value and replaceable attribute corresponding to each buried point code from a preset buried point code template;
[0008] Match the target key value with the corresponding attribute key value of each abstract syntax tree segment to determine the target annotation segment mapped by each buried point code;
[0009] Combine the replaceable attribute corresponding to each buried point code with the target annotation segment mapped by each buried point code, and output the entity buried point code.
[0010] In a possible implementation, the step of converting the script language of the target website into a set of abstract syntax trees includes:
[0011] Scan the script language of the target website through a compiler to generate a mapping array, where the mapping array includes multiple mapping objects, and the mapping object includes the text form, code type, and location corresponding to the current code segment;
[0012] Generate a set of abstract syntax trees according to the syntax rules of the script language from the mapping array.
[0013] In a possible implementation, the step of matching the target key value with the corresponding attribute key values of each of the abstract syntax tree fragments to determine the target annotation fragment mapped by each of the buried point codes includes:
[0014] Determine a first target annotation fragment from the abstract syntax tree fragments;
[0015] Match the target key value corresponding to each buried point code with the corresponding attribute key values of each of the first target annotation fragments to determine a second target annotation fragment mapped by each of the buried point codes.
[0016] In a possible implementation, the step of determining a first target annotation fragment from the abstract syntax tree fragments includes:
[0017] Determine a first target annotation fragment based on the button type attribute of each of the abstract syntax tree fragments, where the button type attribute corresponding to each of the abstract syntax tree fragments includes line comments or block comments.
[0018] In a possible implementation, the step of matching the target key value corresponding to each buried point code with the corresponding attribute key values of each of the first target annotation fragments to determine a second target annotation fragment mapped by each of the buried point codes includes:
[0019] Traverse each of the first target annotation fragments to obtain the corresponding attribute key values of each of the first target annotation fragments;
[0020] Traverse the target key values corresponding to each buried point code in the preset buried point code template, and repeatedly perform the following processing: match the first target key value corresponding to the first buried point code with the corresponding attribute key values of each of the first target annotation fragments to map the second target annotation fragment corresponding to the first buried point code.
[0021] In a possible implementation, the method further includes:
[0022] Configure and / or change the replaceable attributes in the preset buried point code template.
[0023] In a possible implementation, before the step of obtaining the target key value and the replaceable attributes corresponding to each buried point code from the preset buried point code template, it further includes:
[0024] Convert each buried point code in the preset buried point code template into a JSON object, where the JSON object includes at least one replaceable attribute, each JSON object corresponds to a corresponding target key value, and the replaceable attributes correspond to the unique target key value of the JSON object to which they belong.
[0025] In a possible implementation, the target key value is randomly generated for the JSON object by a third-party tool.
[0026] In a possible implementation, before the step of outputting the entity buried point code by combining the replaceable attribute corresponding to each buried point code with the target annotation segment mapped by each buried point code, the method further includes:
[0027] Placing the target annotation segment into the dynamic batch implantation buried point process for processing.
[0028] In a possible implementation, the step of combining the replaceable attribute corresponding to each buried point code with the target annotation segment mapped by each buried point code includes:
[0029] Replacing the code text identifier corresponding to the replaceable attribute in the target annotation segment mapped by each buried point code with the content corresponding to the replaceable attribute.
[0030] In a possible implementation, the step of outputting the entity buried point code includes:
[0031] Merging the result processed by the dynamic batch implantation buried point process with the target annotation segment;
[0032] Converting the merged target annotation segment into an entity buried point code for output through a compiler.
[0033] In a possible implementation, the method further includes:
[0034] Collecting targeted user data for the target website based on the entity buried point code.
[0035] In a second aspect, a buried point device based on mapping configuration is provided, including:
[0036] A conversion module, configured to convert the script language of a target website into a set of abstract syntax trees, where the set of abstract syntax trees includes multiple abstract syntax tree segments;
[0037] An acquisition module, configured to acquire the target key value and the replaceable attribute corresponding to each buried point code from a preset buried point code template;
[0038] A mapping module, configured to match the target key value with the corresponding attribute key value of each abstract syntax tree segment to determine the target annotation segment mapped by each buried point code;
[0039] An output module, configured to combine the replaceable attribute corresponding to each buried point code with the target annotation segment mapped by each buried point code, and output an entity buried point code.
[0040] In a third aspect, an embodiment of the present application further provides an electronic device, including a memory and a processor. A computer program that can run on the processor is stored in the memory. When the processor executes the computer program, the method described in the first aspect above is implemented.
[0041] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and run by a processor, the computer-executable instructions cause the processor to run the method described in the first aspect above.
[0042] The embodiments of the present application bring the following beneficial effects:
[0043] A method, device, electronic device, and storage medium for data tracking based on mapping configuration provided by the embodiments of the present application can achieve fast and convenient data tracking.
[0044] Since there are often many similar code parts in the data tracking process, a large amount of copying and pasting is required in the traditional method, which not only has a large workload but may also cause mistakes and reduce reliability. In this solution, by converting the script language into an abstract syntax tree, based on the mapping relationship between the attribute key values corresponding to the abstract syntax tree fragments and the target key values corresponding to each data tracking code in the preset data tracking code template, the matching target annotation fragments are determined, and the replaceable attributes corresponding to each data tracking code in the preset data tracking code template are combined with their corresponding mapped target annotation fragments to output the entity data tracking code. It is not necessary to know information such as the location of each data tracking code on the website page, and automatic data tracking can be performed based on the mapping relationship, which is convenient and fast.
[0045] To make the above objects, features, and advantages of the present application more obvious and understandable, the following specific preferred embodiments are given and described in detail in conjunction with the accompanying drawings. Description of the Drawings
[0046] To more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the following drawings are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0047] Figure 1 Shows a schematic diagram of the application scenario provided by the embodiment of the present application;
[0048] Figure 2 Is a schematic flowchart of a method for data tracking based on mapping configuration provided by the embodiment of the present application;
[0049] Figure 3 Schematic diagram of a data logging device based on mapping configuration provided by an embodiment of the present application;
[0050] Figure 4 Schematic diagram of an electronic device provided by an embodiment of the present application is shown. Detailed implementation manners
[0051] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions of the present application will be clearly and completely described below with reference to the accompanying drawings. Apparently, the described embodiments are some but not all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the scope of protection of the present application.
[0052] The terms "including" and "having" and any variations thereof mentioned in the embodiments of the present application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes other unlisted steps or units, or optionally further includes other steps or units inherent to these processes, methods, products or devices.
[0053] Currently, in most cases, some third-party data logging services are accessed to complete relevant data collection work. For example, XX Statistics is a commonly used third-party data logging service. The following takes its data logging implantation process as an example for further description. The implantation processes of other data logging services are the same as this one, and no more description will be given here.
[0054] Exemplarily, by inserting the Baidu Statistics data logging initialization script into the body tag of the HTML structure, when the page finishes loading, an instance of the data logging service will be automatically initialized. The specific code can be as follows:
[0055]
[0056] At this time, a global variable _hmt will be initialized. This variable uses the push() function to send some preset parameters to the XX statistics server when the user triggers a specified event, and then realizes data analysis through the XX statistics system to obtain certain statistical results. The relevant code of the push() function needs to be manually added in certain specified events to take effect. Simply put, if there are 100 places in the entire website that need to add data points, then it has to be manually added 100 times. Among them, it can be understood that the push() function is a function method in the XX statistics data point service. push() is used to push a data point record to the server. The above-mentioned specified events can refer to events that the user can operate on, such as button click events, double-click events, long-press events, mouse movement events, scroll events, etc. As an example, add a piece of data point code of the push() function to the click event of a button, as shown in the following code:
[0057] const btn = document.getElementById(“btn”);
[0058] Btn.addEventListener(“click”, () => {
[0059] / / do something
[0060] / / _hmt.push(“_trackEvent”, category, action);
[0061] / / category: The type name of the target to be monitored
[0062] / / action: The action name of the user's interaction with the web page
[0063] _hmt.push(“_trackEvent”, “Login button”, “Login operation - Jump to personal center”);});
[0064] Among them, _hmt.push() in the above code will send preset parameters to the XX statistics server when the user triggers the click event of the button, that is, after the preset logic is executed (jump to the personal center), continue to execute the data point event of XX statistics. Among them, the returned preset parameters are pre-defined parameters. For the above code example, the preset parameters are “Login button” and “Login operation - Jump to personal center”. At this time, the server of the XX statistics data point service will record these data.
[0065] However, if adding XX statistics data points to relatively old front-end projects, this method of adding data point code of the push() function in specified events that the user can operate lacks flexibility, which can be specifically reflected in the following points:
[0066] 1. Since this addition process is not only processed once, but depends on project requirements, and the method of implanting buried points is all manual. If there are many buried points involved, it may involve a large number of mindless copy-and-paste operations, and there is a high possibility of forgetting or copying information incorrectly when implanting code, making the overall implanting process inflexible and unreliable.
[0067] 2. Through research, the inventor found that implanting buried points itself does not belong to the core development process in project requirements. It is just a certain associated method implemented to collect user data. If a large number of buried point codes are implanted during the development stage, it will not only pollute the logical requirements implemented by the global code but also increase the maintenance cost over time.
[0068] 3. Buried point implantation usually occurs in the final step of the development stage. Therefore, during the testing stage, there may be a need to constantly modify the buried point information, but at this time, it can only be modified in the next development stage, which is also a manifestation of inflexibility.
[0069] 4. The overall process of implanting buried points is tightly coupled with the business development process in the development stage, resulting in inseparability. If the buried point service is upgraded or replaced, it will inevitably damage the business process in the development stage, causing the business code to be always affected.
[0070] Based on this, the embodiments of the present application provide a buried point method, device, electronic device, and storage medium based on mapping configuration. Through this method, the technical problems of large workload and low reliability in manually adding buried points can be alleviated.
[0071] For example, as Figure 1 shown, Figure 1 is a schematic diagram of an application scenario provided by the embodiments of the present application. This application scenario may include an intelligent terminal (such as mobile phone 102) and a server 101. The intelligent terminal can communicate with the server 101 through a wired network or a wireless network. The intelligent terminal is used to run a website page, and through this website page, it can interact with the server 101 to achieve editing of the content in the server 101.
[0072] The following further introduces the embodiments of the present application with reference to the accompanying drawings.
[0073] Figure 2 is a schematic flowchart of a buried point method based on mapping configuration provided by the embodiments of the present application. Among them, this method is applied to intelligent devices or intelligent systems such as intelligent terminals configured with browsers, Android systems, etc., and the browser uses a third-party buried point service. As Figure 2 shown, this method includes:
[0074] Step S102: Convert the script language of the target website into a set of abstract syntax trees, where the set of abstract syntax trees includes multiple abstract syntax tree fragments.
[0075] It should be noted that the target website is the website page displayed or running on the current browser. The script language of this target website is JavaScript code, which is used to develop all applications based on the browser kernel. An abstract syntax tree (AST) is an abstract representation of the syntax structure of source code. It represents the syntax structure of a programming language in a tree-like form, and each node on the tree represents a structure in the source code.
[0076] For example, in this step, the representation form of the script language of the target website can be converted into an AST. The script language of the target website is not limited to JavaScript code, and can also include other code representation forms that can be converted into an AST.
[0077] Step S104: Obtain the target key values and replaceable attributes corresponding to each buried point code from the preset buried point code template.
[0078] Among them, the buried point code also belongs to JavaScript code, and the buried point service is just a website business requirement. The target key values and replaceable attributes corresponding to the code that needs to be implanted with buried points can be pre-configured in the preset buried point code template. The target key value is used to map and associate the preset buried point code with the corresponding code fragment in the abstract syntax tree. The replaceable attribute can be understood as the part where each buried point code is different, or the part that the user needs to configure and modify in the preset buried point code template.
[0079] Step S106: Match the target key value with the corresponding attribute key value of each abstract syntax tree fragment to determine the target annotation fragment mapped by each buried point code.
[0080] It should be noted that the abstract syntax tree fragment that matches successfully based on the target key value and the attribute key value is the target annotation fragment mapped by the buried point code corresponding to the target key value.
[0081] Step S108: Combine the replaceable attribute corresponding to each buried point code with the target annotation fragment mapped by each buried point code, and output the entity buried point code.
[0082] Among them, through the research of the inventors, it is found that for most of the same code in the statistical data point embedding service, where only the parameter part is different in requirements, only the parameter part will be inserted in a certain form, replacing the traditional operation of a large number of copy-paste operations for each data point. For example, in this step, the user sets the replaceable attributes of the data point embedding code to be implanted through preset settings, maps them to the corresponding target annotation segments based on the key values, and combines the replaceable attributes corresponding to each data point embedding code with their mapped target annotation segments to achieve a more convenient data point embedding code implantation without a large number of copy-paste operations.
[0083] In a preferred embodiment of practical application, since there are often many similar code parts in the data point embedding process, the traditional method of a large number of copy-paste operations not only has a large workload but may also cause mistakes and reduce reliability. In this solution, by converting the script language into an abstract syntax tree, based on the mapping relationship between the attribute key values corresponding to the abstract syntax tree segments and the target key values corresponding to each data point embedding code in the preset data point embedding code template, the matching target annotation segments are determined, and the replaceable attributes corresponding to each data point embedding code in the preset data point embedding code template are combined with their corresponding mapped target annotation segments to output the entity data point embedding code. Without knowing the location of each data point embedding code on the website page and other information, automatic data point embedding can be performed based on the mapping relationship, which is convenient and fast.
[0084] In the embodiment of the present invention, no data point embedding service code is added to the source code during the development stage. Instead, the data point embedding is implanted into the packaged code during the production stage, completely separating the overall process of data point embedding from the business development process. This ensures the cleanliness, independence, and uniqueness of the source code in the development stage, and at the same time enables the realization of the data point embedding requirements. The ultimate goal of the technical solution of the present invention is to gracefully separate the overall process of data point embedding from the business development process in an automated build manner, so that the two independent processes are not affected by each other and do not cause some problems in project quality assurance. The two are merged during the final packaging and output process of the project code. From the perspective of developers, the two are completely independent and do not affect each other. From the perspective of users, the data point embedding meets the project requirements and can be correctly triggered.
[0085] The following embodiments are described by taking the data point embedding code of XX statistics as an example. Of course, other third-party data point embedding services can also be used. The embodiment of the present invention is based on a custom preset data point embedding code template and can be extended to any third-party data point embedding service.
[0086] In some embodiments, the script language of the website page can be converted based on the abstract syntax tree to enable the implantation of batch data point embedding codes in subsequent steps, achieving a more convenient and fast effect. As an example, the above step S102 may include the following steps:
[0087] Step 1.1), scan the script language of the target website through a compiler to generate a mapping array, where the mapping array includes multiple mapping objects.
[0088] Exemplarily, scan each character of the JavaScript code of the script language through the lexical analysis of the compiler babel, generate mapped corresponding Tokens according to the tokenization rules of the compiler babel and remove whitespace comments, and combine the Tokens into a Token mapping array. A Token is an object that can be used to describe the location of the current code snippet in the entire code and record some information about the current object.
[0089] It should be noted that the Token mapping object is a mapping of the current code snippet, from which information such as the text form, code type, and location of the corresponding code can be known. It can be understood that the script language code and the mapping object can be converted into each other. For example, the mapping object Token can be converted into code through the combination of the information represented in the mapping object, and vice versa.
[0090] Step 1.2), generate a set of abstract syntax trees from the mapping array according to the syntax rules of the script language.
[0091] Among them, the set of abstract syntax trees is an array composed of abstract syntax tree fragments. In some embodiments, based on the above Step 1.1)-Step 1.2), an array composed of AST fragments corresponding to all comment fragments of the script language can be obtained and marked as A.
[0092] In some embodiments, based on the matching of key values, the mapping between the code to be instrumented and the target comment fragment of the script can be realized to achieve the effect of quickly implanting the instrumentation code. As an example, the above Step S106 may include the following steps:
[0093] Step 2.1), determine the first target comment fragment from the abstract syntax tree fragments.
[0094] As an optional embodiment, based on the above Step 2.1), the following steps may further be included:
[0095] Step 2.1.1), determine the first target comment fragment based on the button type attribute of each abstract syntax tree fragment, where the button type attribute corresponding to each abstract syntax tree fragment includes line comments or block comments.
[0096] Among them, the button type attribute is used to define a submit button in the form of an image.
[0097] Exemplarily, by parsing the Token mapping array through the syntax analysis of the compiler babel, an abstract syntax tree set is generated according to the JavaScript syntax rules. The abstract syntax tree set contains the abstract syntax tree fragments of the current code. After converting the script language into the abstract syntax tree set, the button type attribute corresponding to the abstract syntax tree fragment is CommentLine (line comment) or CommentBlock (block comment). Therefore, all first target comment fragments that meet the requirements can be found through this button type attribute feature. As an alternative embodiment, the embodiment of the present invention uses the identifier with the button type attribute of line comment as the target comment fragment feature.
[0098] Step 2.2), match the target key value corresponding to each buried point code with the attribute key value corresponding to each first target comment fragment to determine the second target comment fragment mapped by each buried point code.
[0099] In some embodiments, based on the characteristics of the JSON object, the effect of quickly implanting the buried point code is achieved. As an example, before the above step S104, the following steps may further be included:
[0100] Step 3.1), convert each buried point code in the preset buried point code template into a JSON object, where the JSON object includes at least one replaceable attribute, each JSON object corresponds to a corresponding target key value, and the replaceable attributes correspond to a unique target key value according to the JSON object to which they belong.
[0101] Among them, the full name of JSON is JavaScript Object Notation. JSON is an object representation method of JavaScript. JSON can be understood as a lightweight text data exchange format. It is smaller, faster, and easier to parse than the XML format.
[0102] Next, the preset buried point code template used in the embodiment of the present invention and its related usage methods will be introduced.
[0103] In some embodiments, the preset buried point code template can be embodied in the form of a buried point Excel table file, and its main content is shown in Table 1 below. The buried point content in this table may also be very complex, but it does not prevent the high degree of customization of the embodiment of the present invention, because the overall buried point insertion will use the template combination method to customize the buried point implantation content later, making the buried point more flexible.
[0104] Table 1
[0105]
[0106]
[0107] Exemplarily, the target key value Key corresponding to each buried point code in the above table is unique. In the actual application process, there are many third-party toolkits that can convert the above table into such a JSON object, denoted as B. If the page items in column A of the table are not required, then the target key value Key at this time is unique through the IDs randomly generated by these third-party tools. The converted JSON object is in the following form:
[0108]
[0109]
[0110] Among them, after the buried point content of the above table is JSONified, the form of implanting the buried point code can be defined at this time. Taking the above XX statistical buried point example as an example, the code form for triggering the buried point is _hmt.push("trackEvent", target, action). Then the implanted buried point code is as follows:
[0111] _hmt.push("_trackEvent", $target, $action)
[0112] Among them, $target is the target of the single target key value Key of the above JSON object, and $action is the action of the single target key value Key of the above JSON object.
[0113] In some embodiments, based on the first target annotation segment, and then according to the matching of key values, map the final second target annotation segment, so that the second target annotation segment is output and applied in subsequent steps to implement the implantation of batch buried point codes. As an example, step 2.2) in the above embodiment may further include the following steps:
[0114] Step 2.2.1), traverse each first target annotation segment to obtain the attribute key value corresponding to each first target annotation segment;
[0115] Step 2.2.2), traverse the target key values corresponding to each buried point code in the preset buried point code template, and repeat the following processing: match the first target key value corresponding to the first buried point code with the attribute key values corresponding to each first target annotation segment, and map the second target annotation segment corresponding to the first buried point code.
[0116] As an example, if the target key value Key is ab, then the output code text is _hmt.push("_trackEvent", "_login button", "_login user").
[0117] In some embodiments, based on the first target annotation segment, and then according to the matching of key values, the final second target annotation segment is mapped, so that the second target annotation segment is applied in subsequent steps for output, realizing the implantation of batch buried point code. As an example, step S108 in the above embodiments may further include the following steps:
[0118] Step 4.1), place the target annotation segment into the dynamic batch implantation buried point process for processing.
[0119] After the abstract syntax tree set of all codes is generated, in the subsequent process of traversing the abstract syntax tree segments, the target annotation segments that meet the conditions are found according to the above attribute characteristics (corresponding to all single-line comments in the code). The target annotation segments that meet the conditions are placed into the dynamic batch implantation buried point process for processing, and after the processing result is returned, it is merged into the original target annotation segment. Finally, the compiler will convert the processed target annotation segment into the final output code. At this time, the buried points can be accurately implanted into the final output code in an automated, dynamic, and batch manner without polluting the original development source code.
[0120] Step 4.2), in the target annotation segment mapped by each buried point code, replace the code text identifier corresponding to the replaceable attribute with the content corresponding to the replaceable attribute.
[0121] Regardless of how complex the buried point content of the code is, the identifier in the code text can be replaced with a certain replaceable attribute in the target key Key of a single buried point code in the JSON object in the form of $name, so that highly customized buried point implantation content can be realized. And from beginning to end, the code text is only a text content containing one or more $name expressions.
[0122] For the array A composed of AST segments corresponding to all scripting languages obtained in the foregoing embodiments, at this time, A contains all AST segments with the type attribute of line comment (corresponding to all single-line comments in the code). If the single-line comment form of the target annotation text defined in the embodiments of the present invention is / / track:key, then the single-line comment with the above target key Key being ab is replaced with / / track:ab after replacement. Therefore, the AST segments collected by A actually all correspond to single-line comments such as / / track:ab, / / track:cd, / / track:ef, etc.
[0123] Briefly speaking, by mapping the corresponding annotation content through the target key value Key, no matter how the annotation content changes, it always points to its corresponding target key value Key. Therefore, no matter how the data tracking requirements (the data tracking content in the preset data tracking template) change, when the code is finally packaged and output, the data tracking content will be mapped to the entity code through the specified target key value Key.
[0124] Step 4.3), merge the result of the dynamic batch implantation of data tracking process with the target annotation segment.
[0125] Among them, this process does not require the developer's attention. The embodiments of the present invention can automatically and dynamically batch move the annotation content and merge it with the entity code.
[0126] In the actual application process, each abstract syntax tree segment can be traversed to obtain its attribute value value, and the attribute key Key value in the single-line annotation of the target annotation segment can be extracted through the regular expression " / ^\ / \ / track:(.+?)$ / ". For the above example, it is ab, cd, ef, etc. At this time, in B, obj[key] is a way to quickly access the corresponding attribute value of the object attribute, and the target key value can be obtained, such as B.ab, B.cd, B.ef, and the time complexity is 1. At this time, the final code is generated by combining the pre-defined data tracking code text. Taking key = ab as an example, its corresponding annotation content parameter is {target: "Login button", action: "Login user"}, then the generated final code is _hmt.push("_trackEvent", "Login button", "Login user").
[0127] It should be noted that B was previously generated using a JSON object instead of an array corresponding to the preset data tracking table because accessing a specified attribute in an array requires traversing the array members and making judgments and readings, and the time complexity is N. Therefore, when B is saved in the form of a JSON object, it is more convenient to obtain the corresponding annotation content parameter {target: "xxx", action: "yyy"}.
[0128] Step 4.4), convert the merged target annotation segment into entity data tracking code and output it through a compiler.
[0129] At this time, replace the original value with this value, and modify the type attribute to the call expression CallExpression. The significance of this processing is to change the original single-line annotation (the data tracking content in the preset data tracking table) into entity code, and replace the data tracking content in the preset data tracking table with the specified entity code when the final code is output. When A is traversed, the entity code corresponding to all abstract syntax tree segments will change from the annotation segment to the real data tracking code.
[0130] In the embodiments of the present invention, entity codes are mapped based on the buried point configuration, and this process realizes automation, dynamicization, and batch processing. Formally, the implanted buried point codes do not affect the source code in the development stage, and the finally packaged and output codes can also collect user behaviors when users browse web pages. Therefore, both the simplicity, independence, and specificity of the source code are guaranteed, and the requirement of implanting buried points is also realized.
[0131] In some embodiments, user data can be collected based on the entity buried point codes output by the embodiments of the present invention to achieve the purpose of statistically analyzing data such as user habits. As an example, the above method may include the following steps:
[0132] Step 5.1), collect targeted user data for the target website based on the entity buried point codes.
[0133] Here, based on the quickly implanted buried point codes, targeted user data can be collected according to user behaviors. For example, when a user clicks button A, parameters are returned to the statistical server at this time, so that the statistical server can analyze the user behavior data and can be used as data support for relevant business platforms.
[0134] In some embodiments, the buried point content can be customized and changed to achieve the purpose of quickly completing multiple different buried points. As an example, the above method may include the following steps:
[0135] Step 6.1), configure and / or change the replaceable attributes in the preset buried point code template.
[0136] Exemplarily, by changing the corresponding replaceable attribute contents in columns A, B, C, etc. in Table 1 above, or adding and configuring the replaceable attributes in column D, the corresponding buried point codes can be generated and implanted according to the corresponding configurations to meet the corresponding buried point statistical requirements.
[0137] Compared with the traditional technical solution of manually implanting buried point codes, the embodiments of the present invention have three major characteristics: automation, dynamicization, and batch processing of the core theme. It makes full use of front-end engineering means to optimize and solve problems, and makes new breakthroughs in the traditional buried point implantation method. Compared with the conventional technical solutions, the technical solutions of the present invention have the following implementation advantages:
[0138] 1. The buried point implantation method becomes fully automatic, solves the defects of the conventional technical solutions with the idea of engineering, replaces the manual copy and paste operation through an automated method, and improves the developer experience.
[0139] 2. Completely separate the embedding of data points from the overall process and the business development process, so that the two independent processes do not affect each other and cause some problems in project quality assurance. Combine the two during the final packaging and output of the project code. From the perspective of developers, both are completely independent and do not affect each other. From the perspective of users, the embedding of data points meets the project requirements and can be correctly triggered.
[0140] 3. The source code in the development stage is retained and exists in an independent and uncontaminated form. The overall code quality is not affected by the strong coupling relationship between the business logic and the data points caused by the subsequent embedding of data points. The final output code contains the data point requirements, and the embedding of data points is achieved gracefully.
[0141] 4. Complete all configurations of the page through a JSON configuration file or a data point code template file. There is no need to pay attention to the position of the target elements in the page. Just identify the target key value Key. Add the corresponding attribute key value Key to the target annotation fragment (single-line comment) of the specified event during the development stage to associate the two. Any subsequent data point requirements can be directly modified in the JSON configuration file or the data point code template file, enabling all data points to be centrally managed. Each time the project code is repackaged, the updated data point requirements can be implanted into the final output code.
[0142] 5. The entire process uses scripts to dynamically splice the data point code and implant the data point code, making full use of front-end engineering means to optimize and solve problems, and making new breakthroughs in the traditional data point embedding method, which is very worthy of promotion to all front-end projects that need to deploy data points.
[0143] Figure 3 A structural schematic diagram of a data point embedding device based on mapping configuration is provided. The device can be applied to intelligent terminals configured with browsers, intelligent devices or intelligent systems such as Android systems, and the browser uses a third-party data point service. As Figure 3 shown, the data point embedding device 300 based on mapping configuration includes:
[0144] A conversion module 301 for converting the script language of the target website into a set of abstract syntax trees, the set of abstract syntax trees including a plurality of abstract syntax tree fragments;
[0145] An acquisition module 302 for acquiring the target key value and replaceable attributes corresponding to each data point code from a preset data point code template;
[0146] A mapping module 303 for matching the target key value with the corresponding attribute key values of each abstract syntax tree fragment to determine the target annotation fragment mapped by each data point code;
[0147] An output module 304 is configured to combine the replaceable attributes corresponding to each of the buried point codes with the target annotation segments mapped by each of the buried point codes, and output entity buried point codes.
[0148] In some embodiments, the conversion module 301 is further specifically configured to scan the script language of the target website through a compiler to generate a mapping array, where the mapping array includes a plurality of mapping objects, and the mapping objects include the text form, code type, and location corresponding to the current code segment; generate an abstract syntax tree set according to the syntax rules of the script language.
[0149] In some embodiments, the mapping module 303 is further specifically configured to determine a first target annotation segment from the abstract syntax tree segments; match the target key values corresponding to each buried point code with the attribute key values corresponding to each of the first target annotation segments to determine a second target annotation segment mapped by each of the buried point codes.
[0150] In some embodiments, the mapping module 303 is further specifically configured to determine a first target annotation segment based on the button type attribute of each of the abstract syntax tree segments, where the button type attribute corresponding to each of the abstract syntax tree segments includes line comments or block comments.
[0151] In some embodiments, the mapping module 303 is further specifically configured to traverse each of the first target annotation segments to obtain the attribute key values corresponding to each of the first target annotation segments; traverse the target key values corresponding to each buried point code in the preset buried point code template, and repeatedly perform the following processing: match the first target key value corresponding to the first buried point code with the attribute key values corresponding to each of the first target annotation segments to map the second target annotation segment corresponding to the first buried point code.
[0152] In some embodiments, the apparatus further includes a customization module (not shown in the figure) for configuring and / or changing the replaceable attributes in the preset buried point code template.
[0153] In some embodiments, before the step of obtaining the target key values and replaceable attributes corresponding to each buried point code from the preset buried point code template, the conversion module 301 is further specifically configured to convert each buried point code in the preset buried point code template into a JSON object, where the JSON object includes at least one replaceable attribute, each JSON object corresponds to a corresponding target key value, and the replaceable attributes correspond to the unique target key values according to the JSON objects to which they belong.
[0154] In some embodiments, the target key values are randomly generated for the JSON objects by a third-party tool.
[0155] In some embodiments, before the step of outputting the entity buried point code by combining the replaceable attribute corresponding to each of the buried point codes with the target annotation segment mapped by each of the buried point codes, the output module 304 is further specifically configured to place the target annotation segment into the dynamic batch implanting buried point process for processing.
[0156] In some embodiments, the output module 304 is further specifically configured to replace the code text identifier corresponding to the replaceable attribute in the target annotation segment mapped by each of the buried point codes with the content corresponding to the replaceable attribute.
[0157] In some embodiments, the output module 304 is further specifically configured to merge the result of the dynamic batch implanting buried point process with the target annotation segment; and convert the merged target annotation segment into an entity buried point code for output through a compiler.
[0158] In some embodiments, the apparatus further includes an application module (not shown in the figure), and based on the entity buried point code, it collects targeted user data for the target website.
[0159] The buried point device based on mapping configuration provided by the embodiments of the present application has the same technical features as the buried point method based on mapping configuration provided by the above embodiments, so it can also solve the same technical problems and achieve the same technical effects.
[0160] An electronic device provided by an embodiment of the present application, such as Figure 4 As shown, the electronic device 400 includes a memory 401 and a processor 402. A computer program that can run on the processor is stored in the memory, and when the processor executes the computer program, it implements the steps of the method provided by the above embodiments.
[0161] See Figure 4 As shown, the electronic device further includes: a bus 403 and a communication interface 404. The processor 402, the communication interface 404, and the memory 401 are connected through the bus 403; the processor 402 is used to execute an executable module stored in the memory 401, such as a computer program.
[0162] Among them, the memory 401 may include a high-speed random access memory (Random Access Memory, abbreviated as RAM), and may also include a non-volatile memory, such as at least one disk memory. Through at least one communication interface 404 (which can be wired or wireless), a communication connection is established between this system network element and at least one other network element, and the Internet, wide area network, local area network, metropolitan area network, etc. can be used.
[0163] The bus 403 can be an ISA bus, a PCI bus, an EISA bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 4 only a bidirectional arrow is used in Figure 4 , but it does not mean that there is only one bus or one type of bus.
[0164] Among them, the memory 401 is used to store a program. After receiving an execution instruction, the processor 402 executes the program. The method executed by the device defined by the process disclosed in any embodiment of the present application can be applied to the processor 402 or implemented by the processor 402.
[0165] The processor 402 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor 402 or by an instruction in software form. The above-mentioned processor 402 can be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it can also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being completed by a hardware decoding processor, or completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 401, and the processor 402 reads the information in the memory 401 and combines its hardware to complete the steps of the above method.
[0166] Corresponding to the above method, an embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and run by the processor, the computer-executable instructions cause the processor to run the steps of the above-mentioned method for embedding points based on mapping configuration.
[0167] The data point device based on mapping configuration provided by the embodiments of the present application can be specific hardware on the device, or software or firmware installed on the device, etc. For the device provided by the embodiments of the present application, its implementation principle and the technical effects produced are the same as those of the foregoing method embodiments. For the sake of brief description, for the parts not mentioned in the device embodiments, reference may be made to the corresponding content in the foregoing method embodiments. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the foregoing described systems, devices, and units can all refer to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0168] In the embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces. The indirect coupling or communication connection of the devices or units can be in electrical, mechanical or other forms.
[0169] For another example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of the devices, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementation manners, the functions marked in the blocks may also occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0170] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0171] In addition, each functional unit in the embodiments provided in the present application may be integrated into a processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
[0172] If the above-mentioned function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the mapping configuration-based data point embedding method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM for short), random access memories (RAM for short), magnetic disks, or optical discs.
[0173] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. In addition, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0174] Finally, it should be noted that: the above-mentioned embodiments are only specific implementation manners of the present application, used to illustrate the technical solutions of the present application, rather than limiting it. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed in the present application can still modify the technical solutions recorded in the foregoing embodiments, or can easily think of changes, or make equivalent replacements for some of the technical features; and these modifications, changes, or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application. All should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A data tracking method based on mapping configuration, characterized in that, the data tracking is implanted into the overall process through an automated construction method, which is completely separated from the business development process; the method includes: converting the script language of the target website into a set of abstract syntax trees, the set of abstract syntax trees including multiple abstract syntax tree fragments; the abstract syntax tree fragment is a source code syntax structure; obtaining the target key value and replaceable attribute corresponding to each data tracking code from a preset data tracking code template; matching the target key value with the corresponding attribute key value of each abstract syntax tree fragment to determine the target annotation fragment mapped by each data tracking code; combining the replaceable attribute corresponding to each data tracking code with the target annotation fragment mapped by each data tracking code to output an entity data tracking code; based on the entity data tracking code, collecting targeted user data for the target website and counting user habits; the replaceable attribute is the parameter part with differences between each data tracking code, or the parameter part that the user needs to configure and modify in the preset data tracking code template in advance; the step of combining the replaceable attribute corresponding to each data tracking code with the target annotation fragment mapped by each data tracking code includes: replacing the code text identifier corresponding to the replaceable attribute in the target annotation fragment mapped by each data tracking code with the content corresponding to the replaceable attribute; the step of matching the target key value with the corresponding attribute key value of each abstract syntax tree fragment to determine the target annotation fragment mapped by each data tracking code includes: determining a first target annotation fragment from the abstract syntax tree fragment; matching the target key value corresponding to each data tracking code with the corresponding attribute key value of each first target annotation fragment to determine a second target annotation fragment mapped by each data tracking code; the step of determining a first target annotation fragment from the abstract syntax tree fragment includes: determining a first target annotation fragment based on the button type attribute of each abstract syntax tree fragment, wherein the button type attribute corresponding to each abstract syntax tree fragment includes line comment or block comment.
2. The method according to claim 1, characterized in that, the step of converting the script language of the target website into a set of abstract syntax trees includes: scanning the script language of the target website through a compiler to generate a mapping array, wherein the mapping array includes multiple mapping objects, and the mapping object includes the text form, code type and location corresponding to the current code fragment; generating a set of abstract syntax trees according to the syntax rules of the script language.
3. The method according to claim 1, characterized in that, the step of matching the target key value corresponding to each data tracking code with the corresponding attribute key value of each first target annotation fragment to determine the second target annotation fragment mapped by each data tracking code includes: traversing each first target annotation fragment to obtain the corresponding attribute key value of each first target annotation fragment; Traverse the target key values corresponding to each buried point code in the preset buried point code template, and repeatedly perform the following processing: Match the first target key value corresponding to the first buried point code with the attribute key values corresponding to each of the first target annotation segments, and map the second target annotation segment corresponding to the first buried point code.
4. The method according to claim 1, wherein, the method further includes: configuring and / or changing the replaceable attributes in the preset buried point code template.
5. The method according to claim 1, wherein, before the step of obtaining the target key values and replaceable attributes corresponding to each buried point code from the preset buried point code template, it further includes: Converting each buried point code in the preset buried point code template into a JSON object, where the JSON object includes at least one replaceable attribute, each JSON object corresponds to a corresponding target key value, and the replaceable attributes correspond to a unique target key value according to the JSON object to which they belong.
6. The method according to claim 5, wherein, the target key values are randomly generated for the JSON object by a third-party tool.
7. The method according to claim 1, wherein, before the step of combining the replaceable attributes corresponding to each buried point code with the target annotation segments mapped by each buried point code and outputting the entity buried point code, it further includes: Placing the target annotation segments into the dynamic batch implantation buried point process for processing.
8. The method according to claim 7, wherein, the step of outputting the entity buried point code includes: merging the result processed by the dynamic batch implantation buried point process with the target annotation segments; converting the merged target annotation segments into entity buried point code for output through a compiler.
9. A buried point device based on mapping configuration, wherein, completely separates the buried point implantation overall process from the business development process through an automated construction method; including: a conversion module, configured to convert the scripting language of the target website into a set of abstract syntax trees, the set of abstract syntax trees includes multiple abstract syntax tree segments; the abstract syntax tree segments are a source code syntax structure; an acquisition module, configured to obtain the target key values and replaceable attributes corresponding to each buried point code from a preset buried point code template; a mapping module, configured to match the target key values with the attribute key values of each abstract syntax tree segment to determine the target annotation segments mapped by each buried point code; an output module, configured to combine the replaceable attributes corresponding to each buried point code with the target annotation segments mapped by each buried point code to output entity buried point code; based on the entity buried point code, collect targeted user data for the target website and statistically analyze user habits; the replaceable attributes are the parameter parts with differences between each buried point code, or the parameter parts that the user needs to configure and modify in the preset buried point code template in advance; The output module is further configured to replace the code text identifier corresponding to the replaceable attribute in the target annotation segment mapped by each of the buried point codes with the content corresponding to the replaceable attribute; The mapping module is further configured to determine a first target annotation segment from the abstract syntax tree segment; match the target key value corresponding to each buried point code with the attribute key value corresponding to each of the first target annotation segments to determine a second target annotation segment mapped by each buried point code; The mapping module is further configured to determine a first target annotation segment based on the button type attribute of each of the abstract syntax tree segments, where the button type attribute corresponding to each of the abstract syntax tree segments includes line comments or block comments.
10. An electronic device, comprising a memory and a processor, where a computer program that can run on the processor is stored in the memory, wherein, when the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 above are implemented.
11. A computer-readable storage medium, wherein, the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and run by a processor, the computer-executable instructions cause the processor to run the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Webpage burying point code adding method and device, computer equipment and storage medium
CN111241444A
Point burying method, medium, device and computing equipment
CN112015467A
Buried point setting method and device, computer equipment and storage medium
CN112650659A