You can add any kind of statistics service to your dokuwiki.
Let's start with the more general way:
That will “survive” any dokuwiki upgrade because it is treated as a user document.
If you want to add Google analytics statistics, you can follow the above or simply install this plugin https://www.dokuwiki.org/plugin:googleanalytics
Once installed through the extension manager, you have to go into the configuration manager→Googleanalytics and add your Google Analitycs ID (the alfanumeric code you see in the dashboard of you Google Analytics account).