Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
i have view with data from GA. Results (sessions of current day - ga:sessions) from this views differs from GA query explorer. I think that view refresh data from GA only if i update this view. Views cache is disabled also change of query cache don't help. Any advice?
Comment | File | Size | Author |
---|---|---|---|
#8 | google_analytics_reports-query_cache-2643536-8.patch | 780 bytes | Plazik |
Comments
Comment #2
Plazik CreditAttribution: Plazik as a volunteer commentedHi, Samgarr.
Enable
Show the SQL query
onadmin/structure/views/settings
page.Refresh views page in admin UI and press "Update preview". You should see GA query. Is this the same as you using in GA query explorer?
Clear Drupal cache, refresh views, is the data the same as in GA query explorer?
Default GA cache is 3 days (see
admin/config/system/google-analytics-reports-api
page).I think it's not a good idea to display sessions of current day because it will be always out-of-date.
Comment #3
Samgarr CreditAttribution: Samgarr commentedHi Plazik,
thanks for your reply.
Yes, query is the same.
After flushing Drupal Cache is the data same as in Ga explorer. Is there way how to avoid caching in this case?
Comment #4
Plazik CreditAttribution: Plazik as a volunteer commentedIf you will have only one GA view on your site you can use
hook_form_alter
to change "Query cache" select list onadmin/config/system/google-analytics-reports-api
page.Comment #5
Samgarr CreditAttribution: Samgarr commentedI changed "Query cache" to 60 seconds via custom module with
hook_form_alter
, but issue is the same. After cleaning Drupal cache i get actual results, otherwise i get old results. Isn't there any hardcoded default for query cache?Comment #6
Plazik CreditAttribution: Plazik as a volunteer commentedNo, there is no addition hardcoded default value.
You can call
google_analytics_reports_api_cache_time()
function which return UNIX timestamp when cache should be expire.You can also take a look in database on "cache" table and find "GoogleAnalyticsReportsApiFeed" cache and see when it expires.
Comment #7
Samgarr CreditAttribution: Samgarr commentedgoogle_analytics_reports_api_cache_time
returns correct timestamp according to altered "Query cache".Here is example from cache table.
Comment #8
Plazik CreditAttribution: Plazik as a volunteer commentedIt seems cache doesn't clear properly. Try this patch.
Comment #9
Samgarr CreditAttribution: Samgarr commentedGreat, this is patch working, now i have fresh data! Thank you for you time.
Comment #11
Plazik CreditAttribution: Plazik as a volunteer commented