I have a Swift app with a section that contains a feed of articles. Each article is presented as a web view baked into the app.
The web views are each loaded as the links in the feed are shown, i.e. before the actual view of the article is presented.
I have noticed that Google Analytics considers these preloads to be page views. How can I avoid this? I am able to run JavaScript at the time of the preload as well as when the user navigates to the article. Is it possible to use custom JavaScript to stop GA when the page first loads, then re-enable it when the page is actually displayed?
This is not guaranteed to work but one thing you could explore, providing that you own the GA implementation and the actual articles is to filter out traffic in GA based on a query string param or a campaign param, OR to use some javascript in the articles pages to prevent the GA script from executing.
In your app, upon fetching the list of articles you would append all the URLs in the webviews with a param=value that you would use to build an exclusion rule in the property/view settings in the admin, or instruct your JS in the articles to not execute GA.
On the click on an article you would however remove the param from the URL which would cause GA to behave "normally".
From the GA console: