GA Analytics Ingestion for every href click inside a page

Hi Community,

I’m a newbie in Streamlit and hoping to get some direction on my issue.

I have a requirement that needs to trigger GA ingestion whenever an href link is clicked inside a page. First thing that came to my mind is to trigger the GA ingestion on href click action. However, as I dig through articles, I understand that GA ingestion should be done via header, due to the fact that whenever something changes inside the body will have the event handling loop re-trigger the python code from top to bottom, which will cause the google analytics to refresh and rerun and eventually inflate the number of events.

I would like to understand, is this requirement achievable through streamlit? is there a way to squeeze the GA ingestion on href click action without it being refreshed when some object changes in body as a whole?

here’s the snapshot where we need to trigger GA ingestion when a href link in the list
is clicked.

    for test_id, test_name in meta_dict.items():
        exp_itemized_html += (
            '<li><a href="/Test_Page'
            + f"?test_id={test_id}"
            + ("&mode=search" if is_search_mode else "")
            + f'" target="_self" id={test_id}>`{test_name}_TEST`</a></li>'
        )
    exp_itemized_html += "</ul>"
    st.write(exp_itemized_html, unsafe_allow_html=True)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.