You can track popups with Google Analytics event tracking. This snippet of code may be added to an existing popup or a new one. Learn how by following the below steps.
Navigate to Content > Content Web Content > click the name of the custom popup to begin editing.
Within the Design tab > Signup section > Locate the Input HTML Tag that is tied to the actionable element on the popup.
Add the following attribute to the element that a shopper clicks to submit the popup:
<button onclick="gtag('event', 'click', { 'event_category': 'button', 'event_label': 'signup_button', 'value': 1});">Sign Up</button>
This code translates to:
• gtag('event', 'click', ...): This is the main function used to send events to GA4.
• event_category: This parameter categorizes your events. In this case, we're categorizing it as a "button" click.
• event_label: This provides a more specific label for the event, identifying the particular button that was clicked.
• value: This is an optional parameter to attach a numerical value to the event
💡 The Event Category and the Event Label can be modified to what you would like to show in Google Analytics for this Event.