Overview
Your DNN error logs are displaying the following error:
Evoq.Microservices.Framework.Authorization.TokenException:
Error occurred while obtaining a token for portalId [X] and application Analytics
This log entry may appear when trying to create or edit new pages, or when first enabling Google Analytics. It may be accompanied by errors in the UI with similar wording. This can be caused by a mismatch between site analytics settings in the database and the token used for authentication.
Environment
Though this error often occurs after an update, it can occur on its own. This error is most frequently seen in Evoq versions 9.1.x.
To address this issue, you will need:
- Access to a SuperUser account.
- Access to SQL console or SQL Server
- Access to the file structure for your site
Solution
The solution to this issue involves SQL modification of the site database. As with any solution of this type, it is strongly recommended that you make a complete database backup and test the procedure in a staging environment before attempting it on the production site.
- Log into SSMS or use the SQL Console to run the following commands against the site database:
UPDATE HostSettings
SET SettingValue = 'False' WHERE SettingName IN ('AnalyticsEnabled')
GO
UPDATE PortalSettings
SET SettingValue = 'False' WHERE SettingName IN ('AnalyticsEnabled')
GO
DELETE PortalSettings
WHERE SettingName IN ('AnalyticsAccountCode', 'AnalyticsClientCredentials')
GO - Make a backup of the file ~\Portals\_default\Licenses\Microservices.resources, then delete it.
- Clear your site cache (PersonaBar > Settings > Servers > Clear Cache)
- While still on your site, hard-refresh your browser (CTRL + F5 on Windows, CMD + Shift + R on Mac)
- Go to PersonaBar > Site Analytics. A frame should pop up prompting you to enable the feature. Click next through to the end then Enable Feature.
At this point, you should test the solution. The steps listed above usually solve the problem. If it is still occurring, there is a workaround that can be followed below. This workaround will not fix the Google Analytics integration in DNN Evoq, but it will ensure data is being passed to Google Analytics so that tracking data isn't lost. Tracking data will still be viewable normally through Google's UI.
- Navigate to Settings > Site Settings > Site Behavior > Default Pages
- Add the following Code Snippet to HTML Page Header Tags:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-###########', 'auto');
ga('send', 'pageview');
</script> - Replace UA-########### with the Google Analytics Tracking ID, which can be found in your Google Analytics account.
- Click Save, then clear your site cache and restart the application if possible.
Testing
- Perform the task that previously prompted the log error. If the log errors were created on a time interval rather than per-action, give the site an appropriate amount of time to generate the error.
- Check the error logs. No errors should be present from the time after the fix was applied.
- Data should be tracked through Google Analytics
Comments
0 comments
Please sign in to leave a comment.