User behavior design optimization method, system and equipment based on Webview service and medium
By implementing URL blocking, user token management, behavioral data analysis and personalized page reloading in Hongmeng Webview, the significant problems of traditional Webview in these aspects are solved, and a smoother and more personalized user experience and business optimization effect is achieved.
Patent Information
- Application Number
- CN202510157958.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-06-06
AI Technical Summary
The traditional Hongmeng system Webview has significant problems in URL interception, user token management, behavioral analysis and personalized page reloading, resulting in poor user experience and lack of effective data support for business optimization.
URL blocking is performed by calling the callback function onOverrideUrlLoading in the Webview, obtaining and encrypting the storage user token, calling the custom buried point analysis method userTrace to capture user behavior data, and using the K-Means clustering analysis algorithm to classify users. Finally, the loadUrl method of WebViewController is called in the WebViewController within the Web general event OnPageEnd to reload the personalized URL.
It realizes precise control of Webview URL loading behavior, ensures the security of user tokens, deeply explores and analyzes user behavior data, optimizes the web page display effect and interactive logic, provides users with a smooth and personalized browsing experience, and enhances user stickiness and business value.
Smart Images

Figure CN120104900A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Webview technology, and specifically to a method, system, device and medium for optimizing user behavior design based on Hongmeng Webview service. Background Art
[0002] With the rapid development of mobile Internet technology, Webview, as a technology for efficiently embedding Web pages, has occupied an increasingly important position in mobile application development. However, the traditional Hongmeng system Webview has many significant problems. In terms of URL interception on the Web side, the control lacks sophistication, and it is difficult to flexibly block specific URLs based on business logic and security policies. In addition, the user Token management mechanism is imperfect, and there are security loopholes in the storage and transmission process. At the same time, behavioral analysis can only perform simple page browsing statistics, lacking in-depth data collection methods, resulting in a lack of effective data support for business optimization and user loss. In terms of user behavior data classification, due to the lack of the use of scientific clustering algorithms, users cannot be accurately classified, which greatly affects the recommendation effect and reduces the user's dependence on the application. Finally, when the Web page is reloaded to achieve personalized services, it is impossible for users to switch to the personalized page in a timely and imperceptible manner after the page is loaded. The operation is cumbersome, resulting in a poor user experience.
[0003] Therefore, how to deeply mine and analyze user behavior data, optimize the display effect and interaction logic of web pages, and provide users with a smoother and more personalized browsing experience is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The technical task of the present invention is to provide a method, system, device and medium for optimizing user behavior design based on Hongmeng Webview service to solve the problem of how to deeply mine and analyze user behavior data, optimize the display effect and interaction logic of Web pages, and provide users with a smoother and more personalized browsing experience.
[0005] The technical task of the present invention is achieved in the following way: a method for optimizing user behavior design based on Hongmeng Webview service, which is specifically as follows:
[0006] The Web end calls the callback function onOverrideUrlLoading general event to intercept the corresponding URL and block its own business process: When WebView is about to load the specified URL to the current Web page, the URL loading behavior is controlled by the return value of the callback function onOverrideUrlLoading, and the incoming URL string is deeply analyzed using string parsing technology and pattern matching algorithms, and the loading of specific URLs is intercepted according to custom business logic or rules;
[0007] Get the user token and call the custom tracking analysis method userTrace: When the user successfully logs in, extract the token from the server response data and store it, encrypt and store the token using an encryption algorithm, call the custom tracking analysis method userTrace to capture the user behavior track, and send the tracking data to the server-specific analysis interface; the user behavior track includes click events, page browsing time, and user usage period;
[0008] Use the user's daily data and compare it with the preset database to return a personalized URL link: Use the K-Means clustering analysis algorithm to classify user behavior data, use the user's click count C and stay time T as the two dimensions of the two-dimensional coordinate system (the horizontal axis represents the number of visits, and the vertical axis represents the stay time), and then divide the users into different categories based on the clustering results;
[0009] Call the loadUrl method of WebViewController in the Web common event OnPageEnd to reload the personalized URL and continue your own business: Reload the Web page to implement personalized services. When the OnPageEnd event is triggered, obtain the pre-generated personalized URL link from the local storage or server, and load the personalized URL into the WebView by calling the loadUrl method of WebViewController to achieve seamless page transition and instant display of personalized experience.
[0010] As a preference, the URL loading behavior is controlled by the return value of the callback function onOverrideUrlLoading as follows:
[0011] If the callback function onOverrideUrlLoading returns true, the current web view will stop loading the corresponding URL;
[0012] If the callback function onOverrideUrlLoading returns false, the web view continues to load the corresponding URL according to the established process;
[0013] The callback function onOverrideUrlLoading uses string parsing technology and precise pattern matching algorithms to conduct in-depth analysis of the incoming URL string. For specific URLs that need to be blocked, complex pattern matching is achieved through regular expressions or with the help of simple and efficient string prefix, suffix and inclusion relationship judgment methods.
[0014] Preferably, when the WebView is triggered to load a specific URL, the loading of the corresponding URL is intercepted according to the custom business logic or rules, effectively controlling the path of page navigation and ensuring that the page jump in the Web view meets application expectations and security policies.
[0015] As a preferred method, obtain the user Token and call the custom tracking analysis method userTrace as follows:
[0016] When a user successfully logs in, the server generates a unique Token, and the client parses the response data of the login or authorization interface, extracts the Token and stores it;
[0017] Use the JSON.parse method of ArkTS to convert the response data into an operable object, extract the token attribute and store it locally;
[0018] During the onWindowStageCreate lifecycle of EntryAbility, use preferences.getPreferences to obtain the persistent instance, and after obtaining the Token, use dataPreferences.put to write the data to the cached Preferences instance;
[0019] To ensure the security of Token, Token is stored in the Preferences instance, encrypted using an encryption algorithm, and transmitted in compliance with security protocols to prevent Token from being stolen or tampered with, thus ensuring the confidentiality and integrity of user identity information.
[0020] After receiving the information, the server associates it with the user's Token and stores it in a high-performance database. It also uses advanced data analysis tool algorithms to deeply mine behavioral data, gain insights into behavioral patterns, interest preferences, and potential needs, and provide accurate data basis for the formulation of personalized service strategies, achieving an efficient cycle from data collection to business optimization.
[0021] As a preferred option, the custom tracking analysis method userTrace is used to capture the user behavior trajectory in the Hongmeng client, providing data support for in-depth user behavior analysis and precise business optimization. The tracking scope includes various interactive behaviors, including click events, page browsing time and user usage period;
[0022] The custom tracking analysis method userTrace is the key to data collection. It integrates and transmits user behavior data to ensure that key behaviors are accurately recorded and analyzed. The custom tracking analysis method userTrace has built-in clicks, browsingTime, and userUsagePeriod fields to record user app usage habits, and then sends the tracking data to the server-specific analysis interface.
[0023] As a preferred method, the K-Means clustering analysis algorithm is used to classify the user behavior data as follows:
[0024] Data collection: By collecting APP usage behavior data, each record is regarded as a point in two-dimensional space, forming a data set containing "user token, number of web page visits, and length of stay", which is convenient for subsequent efficient K-Means clustering analysis;
[0025] Determine the number of clusters K: Determine the K value based on business needs or relevant experience. From a business perspective, divide users into three categories based on their activity and other characteristics: high-visit and high-retention users, medium-visit and medium-retention users, and low-visit and low-retention users, and then set the corresponding K value;
[0026] Initialize the cluster center: randomly select 3 data points C from the data set 1 (1,1),C 2 (5,5),C 3 (10,10) is used as the initial cluster center. Each cluster center consists of two dimensions: the number of visits and the length of stay. The form is (1,1), which means one visit and one stay.
[0027] Assign data points: For each data point, the Euclidean distance formula is used to calculate the distance between the data point and the cluster center. The formula is as follows:
[0028]
[0029] It is composed of two-dimensional data and the calculation formula is as follows:
[0030]
[0031] Among them, C k1 and C k2 They are cluster centers C k The values of the number of visits and the length of stay in two dimensions; x i With y i For data points (x i ,y i ); i represents the data point number. After calculation, if Min(d 1 ,d 2 ,d 3 ) = d 2 , then the data point (x i ,y i ) is assigned to the cluster C to which the cluster center is closer 2 ; Using the same method, distance calculation and cluster assignment are performed on all data points;
[0032] Update cluster centers: After all data points are assigned to corresponding clusters, recalculate the cluster center of each cluster; for each cluster, the value of the new cluster center in each dimension is the average value of all data points in the corresponding cluster in the corresponding dimension; suppose after the assignment, there are n 1 Data points are assigned to cluster 1, corresponding to cluster center C 1 ; data point is x i1 ,y i1 , i represents the data point number belonging to cluster 1, then the new cluster center C 1 ' is calculated as follows:
[0033]
[0034] Find the average value C′ in the dimension of visit number 11 ;
[0035]
[0036] Find the average value C′ in the dimension of residence time 12 ;
[0037] Iteration: Repeat the process of assigning data points to clusters and updating cluster centers until the changes in cluster centers are no longer significant, and the number of iterations is no less than 10 times.
[0038] After many iterations, we finally achieved a stable clustering effect. Each data point was classified into the corresponding cluster, thereby dividing the users into different categories such as high-visit and high-retention users, medium-visit and medium-retention users, and low-visit and low-retention users. Subsequently, based on the clustering results, we returned targeted personalized recommendation URLs to more effectively serve different types of user groups.
[0039] Preferably, after the OnPageEnd event is triggered, it is as follows:
[0040] Obtain a pre-generated personalized URL link from local storage or server, which contains page content and service information carefully customized according to user behavior and preferences;
[0041] By calling the loadUrl method of WebviewController, the personalized URL can be efficiently loaded into WebView, achieving seamless page transition and instant display of personalized experience;
[0042] After the initial page loading is completed, it will immediately switch to the personalized page, providing users with highly customized content presentation, function recommendation and interactive experience, ensuring that users can enjoy exclusive personalized services in familiar business processes, and effectively and significantly improving the user stickiness and commercial value of Web applications.
[0043] A user behavior design optimization system based on Hongmeng Webview service, the system is used to implement the user behavior design optimization method based on Hongmeng Webview service as mentioned above; the system includes:
[0044] The interception module is used by the Web end to call the callback function onOverrideUrlLoading general event to intercept the corresponding URL and block its own business process. Specifically, when the WebView is about to load the specified URL to the current Web page, the URL loading behavior is controlled by the return value of the callback function onOverrideUrlLoading, and the incoming URL string is deeply analyzed using string parsing technology and pattern matching algorithms, and the loading of specific URLs is intercepted according to custom business logic or rules;
[0045] The acquisition module is used to obtain the user Token and call the custom tracking analysis method userTrace. Specifically, when the user successfully logs in, the Token is extracted from the server response data and stored, the Token is encrypted and stored using an encryption algorithm, the custom tracking analysis method userTrace is called to capture the user behavior trajectory, and the tracking data is sent to the server-specific analysis interface; the user behavior trajectory includes click events, page browsing time, and user usage period;
[0046] The classification module is used to compare and analyze the user's daily data with the preset database and return a personalized URL link. Specifically, the K-Means clustering analysis algorithm is used to classify the user behavior data. The number of user clicks C and the stay time T are used as the two dimensions of the two-dimensional coordinate system (the horizontal axis represents the number of visits and the vertical axis represents the stay time), and the users are then divided into different categories according to the clustering results.
[0047] The loading module is used to call the loadUrl method of WebViewController in the Web general event OnPageEnd to reload the personalized URL and continue its own business. Specifically: the Web page is reloaded to implement personalized services. When the OnPageEnd event is triggered, the pre-generated personalized URL link is obtained from the local storage or server, and the personalized URL is loaded into the WebView by calling the loadUrl method of WebViewController, so as to achieve seamless page transition and instant display of personalized experience.
[0048] An electronic device comprising: a memory and at least one processor;
[0049] Wherein, the memory stores a computer program;
[0050] The at least one processor executes the computer program stored in the memory, so that the at least one processor executes the user behavior design optimization method based on Hongmeng Webview service as mentioned above.
[0051] A computer-readable storage medium having a computer program stored therein, wherein the computer program can be executed by a processor to implement the user behavior design optimization method based on the Hongmeng Webview service as described above.
[0052] The Hongmeng Webview service user behavior design optimization method, system, device and medium of the present invention have the following advantages:
[0053] (I) The present invention realizes precise control of the URL loading behavior on the Web side through the onOverrideUrlLoading callback function, and flexibly meets the URL blocking requirements by combining multiple matching algorithms; in terms of user Token management, encrypted storage and secure transmission ensure its security, and the userTrace customized embedding analysis method comprehensively collects user interaction behavior data to form an efficient data processing and business optimization cycle; the K-Means clustering analysis algorithm is used to accurately divide user categories according to business needs, and multiple iterations are used to ensure accurate and reliable classification, providing strong support for personalized recommendations; with the help of the OnPageEnd event, the user can seamlessly transition to the personalized page after the page is loaded, providing a highly customized experience and effectively improving user stickiness and commercial value;
[0054] (II) The present invention deeply mines and analyzes user behavior data, thereby optimizing the display effect and interactive logic of web pages, providing users with a smoother and more personalized browsing experience; at the same time, it comprehensively improves the Hongmeng Web application experience and business value, and ensures application security by accurately intercepting URLs, securely managing user tokens, scientifically analyzing user behavior data, and realizing personalized page reloading;
[0055] (III) The web end of the present invention uses the onOverrideUrlLoading general event to intercept the corresponding URL, block its own business process, and thereby accurately obtain the user Token, and then call the custom tracking point analysis method userTrace;
[0056] (iv) The present invention uses the userTrace method to collect daily user data, compares and analyzes the daily data with a preset database through a K-Means clustering analysis algorithm, and obtains insights into user behavior characteristics and preferences, thereby generating an adapted personalized URL link;
[0057] (V) Call the loadUrl method of WebviewController in the Web general event OnPageEnd to reload the personalized URL, so that users can naturally transition to the personalized page experience without being disturbed by the business process. This not only improves the customization and satisfaction of the user experience, deepens the user interaction between the Hongmeng client and the Web application, but also helps to improve user stickiness and loyalty from a commercial value perspective, help expand business value, and promote sustainable development and competitiveness. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The present invention is further described below in conjunction with the accompanying drawings.
[0059] Attached Figure 1 A flowchart for designing an optimization method for user behavior based on Hongmeng Webview service. Attached Figure 2 A flowchart for classifying user behavior data using the K-Means clustering analysis algorithm. DETAILED DESCRIPTION
[0060] The following detailed description is made of the Hongmeng Webview service user behavior design optimization method, system, device and medium of the present invention with reference to the drawings and specific embodiments of the specification.
[0061] Embodiment 1:
[0062] As attached Figure 1 As shown, this embodiment provides a method for optimizing user behavior design based on Hongmeng Webview service, and the method is specifically as follows:
[0063] S1. The Web end calls the callback function onOverrideUrlLoading general event to intercept the corresponding URL and block its own business process: When WebView is about to load the specified URL to the current Web page, the URL loading behavior is controlled by the return value of the callback function onOverrideUrlLoading, and the incoming URL string is deeply analyzed using string parsing technology and pattern matching algorithms, and the loading of specific URLs is intercepted according to custom business logic or rules;
[0064] S2. Get the user token and call the custom tracking analysis method userTrace: When the user successfully logs in, extract the token from the server response data and store it, encrypt and store the token using an encryption algorithm, call the custom tracking analysis method userTrace to capture the user behavior track, and send the tracking data to the server-specific analysis interface; the user behavior track includes click events, page browsing time, and user usage period;
[0065] S3. Use the user's daily data and compare it with the preset database to return a personalized URL link: Use the K-Means clustering analysis algorithm to classify the user behavior data, and use the user's click count C and stay time T as the two dimensions of the two-dimensional coordinate system (the horizontal axis represents the number of visits, and the vertical axis represents the stay time), and then divide the users into different categories according to the clustering results;
[0066] S4. Call the loadUrl method of WebViewController in the Web general event OnPageEnd to reload the personalized URL and continue your own business: Reload the Web page to implement personalized services. When the OnPageEnd event is triggered, obtain the pre-generated personalized URL link from the local storage or server, and load the personalized URL into the WebView by calling the loadUrl method of WebViewController to achieve seamless page transition and instant display of personalized experience.
[0067] In step S1 of this embodiment, the loading behavior of the URL is controlled by the return value of the callback function onOverrideUrlLoading as follows:
[0068] If the callback function onOverrideUrlLoading returns true, the current web view will stop loading the corresponding URL;
[0069] If the callback function onOverrideUrlLoading returns false, the web view continues to load the corresponding URL according to the established process;
[0070] The callback function onOverrideUrlLoading in step S1 of this embodiment uses string parsing technology and precise pattern matching algorithm to conduct in-depth analysis on the incoming URL string. For specific URLs that need to be blocked, complex pattern matching is achieved through regular expressions or with the help of simple and efficient string prefix, suffix and inclusion relationship judgment methods.
[0071] In step S1 of this embodiment, when the WebView is triggered to load a specific URL, a decision is made to intercept the loading of the corresponding URL based on the custom business logic or rules, thereby effectively controlling the path of page navigation and ensuring that the page jump in the Web view meets application expectations and security policies.
[0072] In step S2 of this embodiment, obtaining the user token and calling the custom tracking analysis method userTrace are as follows:
[0073] S201. When the user successfully logs in, the server generates a unique Token, and the client parses the response data of the login or authorization interface, extracts the Token and stores it;
[0074] S202. Use the JSON.parse method of ArkTS to convert the response data into an operable object, extract the token attribute and store it locally;
[0075] S203. During the onWindowStageCreate lifecycle of EntryAbility, use preferences.getPreferences to obtain the persistent instance, and after obtaining the Token, use dataPreferences.put to write the data into the cached Preferences instance;
[0076] S204. To ensure the security of the Token, the Token is stored in the Preferences instance and encrypted using an encryption algorithm. The security protocol is followed during transmission to prevent the Token from being stolen or tampered with, thereby ensuring the confidentiality and integrity of the user's identity information.
[0077] S205. After receiving the data, the server associates it with the user's Token and stores it in a high-performance database. It also uses advanced data analysis tools and algorithms to deeply mine behavioral data, gain insights into behavioral patterns, interest preferences, and potential needs, and provide accurate data basis for the formulation of personalized service strategies, thereby achieving an efficient cycle from data collection to business optimization.
[0078] The custom tracking analysis method userTrace in step S2 of this embodiment is used to capture the user behavior trajectory in the Hongmeng client, providing data support for in-depth user behavior analysis and precise business optimization. The tracking scope includes various types of interactive behaviors, including click events, page browsing time and user usage period;
[0079] The custom tracking analysis method userTrace is the key to data collection. It integrates and transmits user behavior data to ensure that key behaviors are accurately recorded and analyzed. The custom tracking analysis method userTrace has built-in clicks, browsingTime, and userUsagePeriod fields to record user app usage habits, and then sends the tracking data to the server-specific analysis interface.
[0080] As attached Figure 2 As shown, the K-Means clustering analysis algorithm is used to classify the user behavior data in step S3 of this embodiment as follows:
[0081] S301, data collection: by collecting APP usage behavior data, each record is regarded as a point in two-dimensional space, forming a data set including "user token, number of web page visits, and length of stay", which is convenient for subsequent efficient K-Means clustering analysis;
[0082] S302, determine the number of clusters K: determine the K value based on business needs or relevant experience, and from a business perspective, divide users into three categories according to characteristics such as activity, namely, high-visit high-retention users, medium-visit medium-retention users, and low-visit low-retention users, and then set the corresponding K value;
[0083] S303, Initialize cluster center: Randomly select 3 data points C from the data set 1 (1,1),C 2 (5,5),C 3 (10,10) is used as the initial cluster center. Each cluster center consists of two dimensions: the number of visits and the length of stay. The form is (1,1), which means one visit and one stay.
[0084] S304, assigning data points: for each data point, the distance between the data point and the cluster center is calculated using the Euclidean distance formula, the formula is as follows:
[0085]
[0086] It is composed of two-dimensional data and the calculation formula is as follows:
[0087]
[0088] Among them, C k1 and C k2 They are cluster centers C k The values of the number of visits and the length of stay in two dimensions; x i With y i For data points (x i ,y i ); i represents the data point number. After calculation, if Min(d 1 ,d 2 ,d 3 ) = d 2 , then the data point (x i ,y i ) is assigned to the cluster C to which the cluster center is closer 2 ; Using the same method, distance calculation and cluster assignment are performed on all data points;
[0089] S305, update cluster centers: after all data points are assigned to corresponding clusters, recalculate the cluster center of each cluster; for each cluster, the value of the new cluster center in each dimension is the average value of all data points in the corresponding cluster in the corresponding dimension; suppose after the assignment, there are n 1 Data points are assigned to cluster 1, corresponding to cluster center C 1 ; data point is x i1 ,y i1 , i represents the data point number belonging to cluster 1, then the new cluster center C 1 ' is calculated as follows:
[0090]
[0091] Find the average value C′ in the dimension of visit number 11 ;
[0092]
[0093] Find the average value C′ in the dimension of residence time 12 ;
[0094] S306, iterative repetition: repeatedly assigning data points to clusters and updating cluster centers until the change of cluster centers is no longer significant, and the number of iterations is not less than 10 times;
[0095] S307. After multiple iterations, a stable clustering effect is finally achieved. Each data point is classified into a corresponding cluster, thereby dividing different categories such as high-visit and high-retention users, medium-visit and medium-retention users, and low-visit and low-retention users. Subsequently, based on the clustering results, targeted personalized recommendation URLs are returned to more effectively serve different types of user groups.
[0096] After the OnPageEnd event is triggered in step S4 of this embodiment, the details are as follows:
[0097] S401, obtaining a pre-generated personalized URL link from local storage or a server, where the personalized URL link contains page content and service information carefully customized according to user behavior and preferences;
[0098] S402, by calling the loadUrl method of WebviewController, the personalized URL is efficiently loaded into the WebView, so as to achieve seamless transition of pages and instant display of personalized experience;
[0099] S403. After the initial page loading is completed, switch to the personalized page immediately to provide users with highly customized content presentation, function recommendation and interactive experience, ensure that users can enjoy exclusive personalized services in familiar business processes, and effectively and significantly improve the user stickiness and commercial value of Web applications.
[0100] Embodiment 2:
[0101] This embodiment provides a system for optimizing user behavior design based on Hongmeng Webview service, which is used to implement the method for optimizing user behavior design based on Hongmeng Webview service in Embodiment 1; the system includes:
[0102] The interception module is used by the Web end to call the callback function onOverrideUrlLoading general event to intercept the corresponding URL and block its own business process. Specifically, when the WebView is about to load the specified URL to the current Web page, the URL loading behavior is controlled by the return value of the callback function onOverrideUrlLoading, and the incoming URL string is deeply analyzed using string parsing technology and pattern matching algorithms, and the loading of specific URLs is intercepted according to custom business logic or rules;
[0103] The acquisition module is used to obtain the user Token and call the custom tracking analysis method userTrace. Specifically, when the user successfully logs in, the Token is extracted from the server response data and stored, the Token is encrypted and stored using an encryption algorithm, the custom tracking analysis method userTrace is called to capture the user behavior trajectory, and the tracking data is sent to the server-specific analysis interface; the user behavior trajectory includes click events, page browsing time, and user usage period;
[0104] The classification module is used to compare and analyze the user's daily data with the preset database and return a personalized URL link. Specifically, the K-Means clustering analysis algorithm is used to classify the user behavior data. The number of user clicks C and the stay time T are used as the two dimensions of the two-dimensional coordinate system (the horizontal axis represents the number of visits and the vertical axis represents the stay time), and the users are then divided into different categories according to the clustering results.
[0105] The loading module is used to call the loadUrl method of WebViewController in the Web general event OnPageEnd to reload the personalized URL and continue its own business. Specifically: the Web page is reloaded to implement personalized services. When the OnPageEnd event is triggered, the pre-generated personalized URL link is obtained from the local storage or server, and the personalized URL is loaded into the WebView by calling the loadUrl method of WebViewController, so as to achieve seamless page transition and instant display of personalized experience.
[0106] As attached Figure 1 As shown in the figure, the working process of the system is as follows:
[0107] (1) Web-side URL interception and business process blocking, as follows:
[0108] ① When the Web View is about to load the specified URL to the current Web page, the host application will get an opportunity to intervene and control the process. Specifically, through the return value of the callback function onOverrideUrlLoading, the developer can influence the loading behavior of the URL: if the callback function returns true, the current Web View will stop loading the URL; conversely, if it returns false, the Web View will continue to load the URL according to the established process.
[0109] ② As the core event interface provided by WebView, onOverrideUrlLoading gives developers the key decision-making power in the URL loading process. Inside the onOverrideUrlLoading method, string parsing technology and precise pattern matching algorithms are used to conduct in-depth analysis of the incoming URL string. For those specific URLs that need to be blocked, regular expressions can be used to match complex patterns, and simple and efficient string prefix, suffix, and inclusion relationship judgment methods can also be used to achieve the corresponding purpose.
[0110] ③Whenever WebView is ready to load a specific URL, the system triggers this event. At this time, based on the custom business logic or rules, it decides to intercept the loading of the URL. In this way, the path of page navigation can be effectively controlled to ensure that the page jump in the Web view meets the application expectations and security policies.
[0111] (2) Obtain the user token and call the custom tracking analysis method userTrace, as follows:
[0112] ① User Token, as a digital identification of user identity, is of great significance in the security and personalized service system of Hongmeng Web applications.
[0113] ②When the user successfully logs in, the server generates a unique Token, and the client parses the response data of the login or authorization interface, extracts the Token and stores it.
[0114] ③ Use the JSON.parse method of ArkTS to convert the response data into an operable object, extract the token attribute and store it locally. During the onWindowStageCreate lifecycle of EntryAbility, use preferences.getPreferences to obtain the persistent instance, and after obtaining the Token, use dataPreferences.put to write the data to the cached Preferences instance.
[0115] ④ To ensure the security of Token, encryption algorithm is used for encrypted storage and security protocol is followed during transmission to prevent Token from being stolen or tampered with, thus ensuring the confidentiality and integrity of user identity information.
[0116] ⑤ The custom tracking analysis method userTrace is used to capture the user behavior trajectory in the Hongmeng client, providing data support for in-depth user behavior analysis and precise business optimization. The tracking range includes various interactive behaviors, such as click events, page browsing time, user usage time period, etc.
[0117] ⑥The userTrace function is the key to data collection. It integrates and transmits user behavior data to ensure that key behaviors are accurately recorded and analyzed. It has built-in clicks, browsingTime, and userUsagePeriod fields to record user app usage habits, and then sends the embedded data to the server's dedicated analysis interface.
[0118] ⑦ After receiving, the server associates it with the user's Token and stores it in a high-performance database. With advanced data analysis tool algorithms, we can deeply mine behavioral data, gain insights into behavioral patterns, interest preferences and potential needs, provide accurate data basis for the formulation of personalized service strategies, and achieve an efficient cycle from data collection to business optimization.
[0119] (3) K-Means clustering analysis algorithm is used to classify user behavior data. In the algorithm, the number of user clicks C and the dwell time T are used as the two dimensions of the two-dimensional coordinate system. The horizontal axis represents the number of visits and the vertical axis represents the dwell time. The details are as follows:
[0120] ① Data collection: By collecting APP usage behavior data, each record is regarded as a point in two-dimensional space, forming a data set containing "user token, number of web page visits, and length of stay", which is convenient for subsequent efficient K-Means clustering analysis.
[0121] ② Determine the number of clusters K: Determine the K value based on business needs or relevant experience. From a business perspective, the present invention divides users into three categories according to characteristics such as activity: high-visit and high-retention users, medium-visit and medium-retention users, and low-visit and low-retention users, and sets the corresponding K value.
[0122] ③ Initialize the cluster center: randomly select 3 data points C from the data set 1 (1,1),C 2 (5,5),C 3 (10,10) is used as the initial cluster center. Each cluster center consists of values in two dimensions: number of visits and length of stay. For example, (1,1) means one visit and one stay of 1s.
[0123] ④ Assign data points: For each data point, use the Euclidean distance formula to calculate the distance between the data point and the cluster center:
[0124]
[0125] It is composed of two-dimensional data and the calculation formula is:
[0126]
[0127] Among them C k1 and C k2 They are cluster centers C k The values of x in terms of the number of visits and the length of stay. i With y i For data points (x i ,y i ), where i is the data point number. After calculation, if Min(d 1 ,d 2 ,d 3 ) = d 2 , then the data point (x i ,y i ) is assigned to the cluster C to which the cluster center is closer 2 In the same way, distance calculation and cluster assignment are performed on all data points.
[0128] ⑤ Update cluster centers: After all data points are assigned to corresponding clusters, the cluster center of each cluster needs to be recalculated. For each cluster, the value of the new cluster center in each dimension is the average value of all data points in the cluster in that dimension. Assume that after the previous step, there are n1 Data points are assigned to cluster 1 (corresponding to cluster center C 1 ), these data points are x i1 ,y i1 (i represents the data point number belonging to cluster 1), then the new cluster center C 1 ' is calculated as follows:
[0129]
[0130] Find the average value C′ in the dimension of the number of visits 11 .
[0131]
[0132] Find the average value C′ in the dimension of stay time 12 .
[0133] ⑥ Iteration repetition: Repeat the two steps of assigning data points to clusters and updating cluster centers until the changes in cluster centers are no longer significant, and the number of iterations is not less than 10 times.
[0134] ⑦ After many iterations, a stable clustering effect is finally achieved, and each data point is classified into the corresponding cluster, thereby dividing different categories such as high-visit and high-retention users, medium-visit and medium-retention users, and low-visit and low-retention users. Subsequently, based on the clustering results, targeted personalized recommendation URLs are returned to more effectively serve different types of user groups.
[0135] (4) Web page reloading realizes personalized service. The OnPageEnd event is a key event in the field of Hongmeng Web development. It indicates that all resources in the page, such as HTML, CSS, JavaScript files and various multimedia resources, have been loaded completely. In this embodiment, this event triggering timing is used as the entry point for personalized services, and the personalized URL is reloaded, so that users can smoothly transition to customized page content without feeling, realize a smooth transition from general browsing to personalized experience, and improve user satisfaction and business participation. After triggering the OnPageEnd event: First, obtain the pre-generated personalized URL link from the local storage or server. This link contains the page content and service information carefully customized according to user behavior and preferences. Then, by calling the loadUrl method of WebviewController, the personalized URL is efficiently loaded into the WebView, achieving seamless page transition and instant display of personalized experience. With this operation, when the page is initially loaded, it will immediately switch to the personalized page, providing users with highly customized content presentation, function recommendations, and interactive experience, ensuring that users can enjoy exclusive personalized services in familiar business processes, effectively and significantly improving the user stickiness and commercial value of Web applications.
[0136] Embodiment 3:
[0137] An embodiment of the present invention further provides an electronic device, comprising: a memory and at least one processor;
[0138] Wherein, the memory stores computer-executable instructions;
[0139] The at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the user behavior design optimization method based on Hongmeng Webview service in any embodiment of the present invention.
[0140] The processor may be a central processing unit (CPU), or 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. The processor may be a microprocessor or any conventional processor, etc.
[0141] The memory can be used to store computer programs and / or modules. The processor realizes various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the terminal, etc. In addition, the memory can also include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, at least one disk storage period, a flash memory device, or other volatile solid-state storage devices.
[0142] Embodiment 4:
[0143] This embodiment also provides a computer-readable storage medium, which stores a plurality of instructions, which are loaded by a processor to enable the processor to execute the method for optimizing user behavior design based on Hongmeng Webview service in any embodiment of the present invention. Specifically, a system or device equipped with a storage medium can be provided, on which a software program code for implementing the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the system or device reads and executes the program code stored in the storage medium.
[0144] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0145] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RYM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer via a communication network.
[0146] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0147] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A user behavior design optimization method based on Hongmeng Webview service, characterized in that: The method is as follows: The Web end calls the callback function onOverrideUrlLoading general event to intercept the corresponding URL and block its own business process: When WebView is about to load the specified URL to the current Web page, the URL loading behavior is controlled by the return value of the callback function onOverrideUrlLoading, and the incoming URL string is deeply analyzed using string parsing technology and pattern matching algorithms, and the loading of specific URLs is intercepted according to custom business logic or rules; Get the user token and call the custom tracking analysis method userTrace: When the user successfully logs in, extract the token from the server response data and store it, encrypt and store the token using an encryption algorithm, call the custom tracking analysis method userTrace to capture the user behavior track, and send the tracking data to the server-specific analysis interface; the user behavior track includes click events, page browsing time, and user usage period; Use the user's daily data and compare it with the preset database to return a personalized URL link: Use the K-Means clustering analysis algorithm to classify user behavior data, use the user's click count C and stay time T as the two dimensions of the two-dimensional coordinate system, and then divide the users into different categories based on the clustering results; Call the loadUrl method of WebViewController in the Web common event OnPageEnd to reload the personalized URL and continue your own business: Reload the Web page to implement personalized services. When the OnPageEnd event is triggered, obtain the pre-generated personalized URL link from the local storage or server, and load the personalized URL into the WebView by calling the loadUrl method of WebViewController to achieve seamless page transition and instant display of personalized experience.
2. According to the method for optimizing user behavior design based on Hongmeng Webview service according to claim 1, it is characterized in that: The URL loading behavior is controlled by the return value of the callback function onOverrideUrlLoading as follows: If the callback function onOverrideUrlLoading returns true, the current web view will stop loading the corresponding URL; If the callback function onOverrideUrlLoading returns false, the web view continues to load the corresponding URL according to the established process; The callback function onOverrideUrlLoading uses string parsing technology and precise pattern matching algorithms to conduct in-depth analysis of the incoming URL string. For specific URLs that need to be blocked, complex pattern matching is achieved through regular expressions or by using string prefixes, suffixes, and inclusion relationship judgments.
3. The method for optimizing user behavior design based on Hongmeng Webview service according to claim 1 is characterized in that: When WebView is triggered to load a specific URL, it decides to intercept the loading of the corresponding URL based on the custom business logic or rules, effectively controlling the path of page navigation and ensuring that the page jump in the Web view meets application expectations and security policies.
4. The method for optimizing user behavior design based on Hongmeng Webview service according to claim 1 is characterized in that: Get the user token and call the custom tracking analysis method userTrace as follows: When a user successfully logs in, the server generates a unique Token, and the client parses the response data of the login or authorization interface, extracts the Token and stores it; Use the JSON.parse method of ArkTS to convert the response data into an operable object, extract the token attribute and store it locally; During the onWindowStageCreate lifecycle of EntryAbility, use preferences.getPreferences to obtain the persistent instance, and after obtaining the Token, use dataPreferences.put to write the data to the cached Preferences instance; The Token is stored in the Preferences instance and encrypted using an encryption algorithm. The transmission follows the security protocol to prevent the Token from being stolen or tampered with, ensuring the confidentiality and integrity of the user's identity information. After receiving the information, the server associates it with the user's Token and stores it in a high-performance database. It also uses advanced data analysis tool algorithms to deeply mine behavioral data, gain insights into behavioral patterns, interest preferences, and potential needs, and provide accurate data basis for the formulation of personalized service strategies, achieving an efficient cycle from data collection to business optimization.
5. The method for optimizing user behavior design based on Hongmeng Webview service according to claim 1 is characterized in that: The custom tracking analysis method userTrace is used to capture the user behavior trajectory in the Hongmeng client, providing data support for in-depth user behavior analysis and precise business optimization. The tracking scope includes various interactive behaviors, including click events, page browsing time and user usage time period; The custom tracking analysis method userTrace is the key to data collection. It integrates and transmits user behavior data to ensure that key behaviors are accurately recorded and analyzed. The custom tracking analysis method userTrace has built-in clicks, browsingTime, and userUsagePeriod fields to record user app usage habits, and then sends the tracking data to the server-specific analysis interface.
6. The method for optimizing user behavior design based on Hongmeng Webview service according to claim 1 is characterized in that: The K-Means clustering analysis algorithm is used to classify user behavior data as follows: Data collection: By collecting APP usage behavior data, each record is regarded as a point in two-dimensional space, forming a data set including "user token, number of web page visits, and length of stay"; Determine the number of clusters K: Determine the K value based on business needs or relevant experience. From a business perspective, divide users into three categories based on their activity and other characteristics: high-visit and high-retention users, medium-visit and medium-retention users, and low-visit and low-retention users, and then set the corresponding K value; Initialize cluster centers: Randomly select three data points C1(1,1), C2(5,5), and C3(10,10) from the data set as initial cluster centers. Each cluster center consists of two dimensions: the number of visits and the length of stay. The form is (1,1), which means one visit and one stay. Assign data points: For each data point, the Euclidean distance formula is used to calculate the distance between the data point and the cluster center. The formula is as follows: It is composed of two-dimensional data and the calculation formula is as follows: Among them, C k1 and C k2 They are cluster centers C k The values of the number of visits and the length of stay in two dimensions; x i With y i For the data point (x i ,y i ); i represents the data point number. After calculation, if Min(d1, d2, d3) = d2, then the data point (x i ,y i ) is assigned to cluster C2, which is a cluster center that is closer to it; in the same way, distance calculation and cluster assignment are performed on all data points; Update cluster centers: After all data points are assigned to corresponding clusters, recalculate the cluster center of each cluster; for each cluster, the value of the new cluster center in each dimension is the average value of all data points in the corresponding cluster in the corresponding dimension; suppose that after the assignment, n1 data points are assigned to cluster 1, corresponding to cluster center C1; the data point is x i1 ,y i1 , i represents the data point number belonging to cluster 1, then the new cluster center C1' is calculated as follows: Find the average value C′ in the dimension of visit number 11 ; Find the average value C′ in the dimension of residence time 12 ; Iteration: Repeat the process of assigning data points to clusters and updating cluster centers until the changes in cluster centers are no longer significant, and the number of iterations is no less than 10 times. After many iterations, we finally achieved a stable clustering effect. Each data point was classified into the corresponding cluster, thereby dividing the users into different categories such as high-visit and high-retention users, medium-visit and medium-retention users, and low-visit and low-retention users. Subsequently, based on the clustering results, we returned targeted personalized recommendation URLs.
7. The method for optimizing user behavior design based on Hongmeng Webview service according to any one of claims 1 to 6, characterized in that: After the OnPageEnd event is triggered, the details are as follows: Obtain a pre-generated personalized URL link from local storage or server, which contains page content and service information carefully customized according to user behavior and preferences; By calling the loadUrl method of WebviewController, the personalized URL can be efficiently loaded into WebView, achieving seamless page transition and instant display of personalized experience; After the initial page loading is completed, it will immediately switch to the personalized page, providing users with highly customized content presentation, function recommendation and interactive experience.
8. A user behavior design optimization system based on Hongmeng Webview service, characterized in that: The system is used to implement the Hongmeng Webview service user behavior design optimization method according to any one of claims 1 to 7; the system includes: The interception module is used by the Web end to call the callback function onOverrideUrlLoading general event to intercept the corresponding URL and block its own business process. Specifically, when the WebView is about to load the specified URL to the current Web page, the URL loading behavior is controlled by the return value of the callback function onOverrideUrlLoading, and the incoming URL string is deeply analyzed using string parsing technology and pattern matching algorithms, and the loading of specific URLs is intercepted according to custom business logic or rules; The acquisition module is used to obtain the user Token and call the custom tracking analysis method userTrace. Specifically, when the user successfully logs in, the Token is extracted from the server response data and stored, the Token is encrypted and stored using an encryption algorithm, the custom tracking analysis method userTrace is called to capture the user behavior trajectory, and the tracking data is sent to the server-specific analysis interface; the user behavior trajectory includes click events, page browsing time, and user usage period; The classification module is used to compare and analyze the user's daily data with the preset database and return a personalized URL link. Specifically, the K-Means clustering analysis algorithm is used to classify the user behavior data, and the number of user clicks C and the stay time T are used as the two dimensions of the two-dimensional coordinate system, and the users are divided into different categories according to the clustering results; The loading module is used to call the loadUrl method of WebViewController in the Web general event OnPageEnd to reload the personalized URL and continue its own business. Specifically: the Web page is reloaded to implement personalized services. When the OnPageEnd event is triggered, the pre-generated personalized URL link is obtained from the local storage or server, and the personalized URL is loaded into the WebView by calling the loadUrl method of WebViewController, so as to achieve seamless page transition and instant display of personalized experience.
9. An electronic device, characterized in that: include: memory and at least one processor; Wherein, the memory stores a computer program; The at least one processor executes the computer program stored in the memory, so that the at least one processor executes the user behavior design optimization method based on Hongmeng Webview service as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which can be executed by a processor to implement the user behavior design optimization method based on Hongmeng Webview service as described in any one of claims 1 to 7.