I have a portal which is a SPA and at the same time single URL app, everything loads on the screen dynamically without the change of URL. My application is actually a chat application where an agent communicates with user and this communication includes various stages, and the final stage is, when a user is displayed with the content of survey screen (URL is still the same as landing page)

Because of which I have created a Goal in GA that if a user stays on my URL for more than 4 mins then My goal is completed, I know this is not the real goal. i cannot figure out how can I trigger any goal from my survey screen.

So here I need to understand:

  • What should be my goal and how to create it?
  • How to trigger my above created goal?

Using Google Tag Manager to track events on a SPA

Like in your single page application, there are times when tracking a goal or conversion is not possible in Google Analytics. GTM (<-link to Google tag manager overview) allows you to create custom events, such as a form being submitted, even when the page is not redirected to a "thank you" page, and then tracking that event.

I think in your case, a history change trigger will be what you need, especially if there are URL fragments created. Within your chat application if the user has to click "send" that can be tracked, once or each time if you like. It comes down to how you configure the trigger to capture the data you need. Or you can create a tag that fires when the final survey is displayed on the screen.

You can find a very detailed walk-through on how to create triggers and track the subsequent events here: HOW TO TRACK SINGLE PAGE WEB APP WITH GOOGLE TAG MANAGER Within the post there is a link that will help you install Google Tag Manager if you haven't yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.