Setting up page load events

You may use page load/page view events as triggers for Display Product Experience. To reliably use these events as triggers, ensure that your event is fired post rendering the screen.
Use the following code snippet to fire page load events in the right methods.

🚧

Page load events for dynamic screens

In case if the App needs to make an API call to fetch the data before rendering the screen, then please trigger the page load once the API call returns and the screen is completed rendered. You can alternatively add delay duration from the Smartech PX dashboard.

import 'package:flutter/material.dart';
import 'package:smartech_base/smartech_base.dart';

class SamplePage extends StatefulWidget{
  const SamplePage({super.key});

  @override
  State<SamplePage> createState() => _SamplePageState();
}

class _SamplePageState extends State<SamplePage> {
  @override
  Widget build(BuildContext context) {
    
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      //Add this if you want to track events through Smartech
      Smartech().trackEvent("page_load_event", {});
      
      //Add this if you want to track events through other analytics. 
      CleverTapAPI.recordEvent("Bottom_Nav", <String,Object>{});
    });
    
    return const Scaffold();
  }
}

🚧

Smartech PX requires page load events to be fired only post rendering the Screen. This is to ensure that the anchored product experience are placed against the right view. You can alternatively add delay duration from the Hansel dashboard.

Note - If used incorrectly, anchored nudges may be skipped when the Screen / Widget has not been rendered