Why is Google Analytics showing index.php after every page URL?

I was checking my Google Analytics today after migrating my blog to Ghost and noticed a weird thing. All the page URLs were contained index.php towards the end!

When I tried opening these pages from GA, all the URLs were throwing 404 error as they contained the same index.php towards the end.

All the URL are linked incorrectly in the Google Analytics

I checked the GA tracking code and it was correct. Also, the analytics data against of the pages seemed to be correct. I further checked the real-time data to be certain.

So, what is the solution?

After tinkering with Google Analytics, I realized this issue was due to an old setting configured when my blog was on Drupal.

I had set default page URL as index.php under View Settings in the Google Analytics.

Default page under View Settings in GA

And voila! The pages started showing up correctly under Real Time dashboard.