Tracking user traffic in your Frontly apps can be helpful for gaining insights into user behaviour and optimizing your app’s performance. With Frontly's custom actions, you can easily implement a page visit tracker to monitor how often users interact with specific pages. By following a few simple steps, you can automatically update the number of visits for each page, giving you real-time data on your user engagement!
The Setup
1. Create and Import a 'Page Visits' Data Source
Create a data source with a "page name" and "page visits" field and import it into Frontly.
Populate the data source with your page names and set the value for each row under 'page visits' to 0.
2. Set Up Page Load Actions
Within each page's 'More' settings, click the Page Load Action button to configure a custom action that's triggered whenever the page loads.
3. Add Two Data Source Request Actions
In the custom action flow, add two 'Data Source Request' actions one below the other.
4. First Action: GET Request
Set the request type to GET.
For the Row ID, enter the page name as it is entered in your data source.
For the Row Column, set it to the 'page' field. Completing this step will retrieve the 'page_visits' value for a specific page.
5. Second Action: Edit Request
Set the request type to EDIT.
Use the same Row ID and Row Column as in the previous GET request.
For the page visits field, reference the value pulled from the previous GET step using the 'Step' variable and make sure to append the 'increment.1' syntax after it, as shown below. This increments the page visits count by 1 every time the page is loaded.
Click here to explore the use cases of the Step Variable.
Click here to learn more about Incrementing Values
Repeat these steps for all the other pages in your app, and using this approach will allow you to track and update the number of visits dynamically and effectively within your Frontly app!