Google Analytics 4 property G-XXXXXXXX

9,368 views
Skip to first unread message

Rui Guerreiro

unread,
Apr 8, 2022, 9:55:04 AM4/8/22
to AtoM Users
Hi everyone!,

The archivist responsible for our AtoM has received in Google Analytics a warning on GA type of key change, UA- to G-, that will happen next year, so she contacted the IT department to apply this change worried on statistics functionality loss... 
To reply to her request I fiddled with config/app and that didn't work. Then searching a bit in github, though I never programmed in PHP, nor I know what am I doing in AtoM!, this hack seams to work:

- in config/app.yml a new property to prevent writing of template _footer GA block and write new GA block next to <head> tag
# Google Analitycs:  
# Set a GA property API key to track page view hits.   
# E.g.: UA-1234567-89   
google_analytics_api_key:   
# hack for v4 keys -> ga block on <head>  
google_analytics_api_key_4: G-XXXXXXXX

- apps/qubit/config/qubitConfiguration.class.php , function responseFilterContent

 public function responseFilterContent(sfEvent $event, $content)
  {
    ProjectConfiguration::getActive()->loadHelpers('Javascript');

    $gaKey = sfConfig::get('app_google_analytics_api_key_4', '');
    if (!empty($gaKey)) {
        $newHead = '<head>'.PHP_EOL;
        $newHead .= '<!-- Global site tag (gtag.js) - Google Analytics -->'.PHP_EOL;
        $newHead .= '<script async src="https://www.googletagmanager.com/gtag/js?id=gaKey"></script>'.PHP_EOL.'<script>'.PHP_EOL;
        $newHead .= 'window.dataLayer = window.dataLayer || [];'.PHP_EOL;
        $newHead .= 'function gtag(){dataLayer.push(arguments);}'.PHP_EOL;
        $newHead .= "gtag('js', new Date());".PHP_EOL.PHP_EOL;
        $newHead .= "gtag('config', 'gaKey');".PHP_EOL."</script>";
        $newHead = str_ireplace('gaKey', $gaKey, $newHead);

        return str_ireplace('</head>', javascript_tag('jQuery.extend(Qubit, '.json_encode(array('relativeUrlRoot' => sfContext::getInstance()->request->getRelativeUrlRoot())).');').'</head>', str_ireplace('<head>', $newHead, $content));
    }
    return str_ireplace('</head>', javascript_tag('jQuery.extend(Qubit, '.json_encode(array('relativeUrlRoot' => sfContext::getInstance()->request->getRelativeUrlRoot())).');').'</head>', $content);
  }

We are using AtoM 2.6.2 and waiting to upgrade to 2.7.

Is there a way to properly use GA 4 G-XXXXXXXX in version 2.6.2? Will it be implemented in version 2.7?

Thanks

Dan Gillean

unread,
Apr 11, 2022, 9:48:49 AM4/11/22
to ICA-AtoM Users
Hi Rui, 

Thanks for bringing this to our attention. Given that I don't think the switch to GA4 was announced when AtoM 2.6.2 was released, there's no official support for G4 in that release. 

To ensure we address this before July 1st, 2023 when Universal Analytics will be deprecated, I've filed the following issue ticket:
As noted on the ticket's comments, I've tagged this for consideration in the upcoming 2.7 release. However, whether or not a fix is included in that particular release may depend on what is involved in supporting the transition. In general, anything that requires a database schema migration we only include in major releases. Given that there's been a longer-than-expected delay between releases 2.6 and 2.7, if a schema migration is required for G4 support, then I would personally want to prioritize support in 2.7 to ensure that no matter what happens with 2.8 release plans, there is a fix available by the time the deprecation date arrives. However, if no schema migration is required, then we will probably not include a fix immediately in 2.7 (to avoid delaying the release any further), and instead aim for a 2.7.x future minor release to include a patch for this. 

Either way, we're now aware of this issue and will look into options for addressing it in the future. We've still got a little over a year to find the best solution! 

Cheers, 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him


--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/a6d1e583-1a45-48d6-9911-d5fc0e28c3fan%40googlegroups.com.

Jim Adamson

unread,
May 31, 2023, 8:35:33 AM5/31/23
to AtoM Users
Just to bring this to people's attention that as of recently-released AtoM 2.7.2, Google Analytics 4 Tracking IDs (or Measurement IDs as they're known in GA4) are supported.

This is the change that added the support:

I'm pleased to say we're now sending our site data to our new GA4 property.

Jim

gomes...@gmail.com

unread,
Jun 6, 2023, 4:21:17 PM6/6/23
to AtoM Users
Hello,

Thank you for making AtoM work with GA4. It came at a good time! 
I would like to bring to your attention that in the full-width treeview, no matter how much you click on several records, that data will not appear in the real-time overview of analytics. However, in the sidebar treeview, it collects the page every time I click on a record, which is the expected behavior. I don’t know if this issue has already happened with the previous versions of analytics. I used freshly installed browsers to test this. 

Thank you again for your work.

Dan Gillean

unread,
Jun 7, 2023, 8:52:35 AM6/7/23
to ica-ato...@googlegroups.com
Hi Gomes, 

Thanks for this report. I have filed the following issue ticket so that our Maintainers can investigate this in the future: 
The full-width treeview uses AJAX to perform partial page reloads, so that the current position in the treeview can be maintained while surrounding partials (the sidebar, the body of the description, etc) can be updated rapidly based on the current tree node selected without requiring a full page reload (which could cause the tree position to be changed/displayed differently in a disorienting way for end users). Because these changes are being injected via AJAX and not via a full PHP request / response page reload from the backend, I suspect this is why the full treeview is not capturing these clicks.... but this is just my theory, I could be wrong!

Hopefully our Maintainers can find a compromise in the future. In the meantime, thanks for the report! 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him

Dan Gillean

unread,
Jul 12, 2023, 2:08:22 PM7/12/23
to ica-ato...@googlegroups.com
Hi again Gomes, 

Our Maintainers have done some initial investigation on this, and they believe that this may be an issue you can fix via configuration. From our conversation: 

We made some more attempts to replicate the issue and we concluded that this issue is most likely due to disabled data stream settings. and there is also the chance that some settings in treeview might affect how analytics tracks information.

When I asked about what they suggested to resolve this, they suggested reviewing your settings in Analytics. Specifically: 

Since there's a chance they might have a setting disabled I think this may help the user:
  • Go to Admin Settings on the bottom of the side bar menu
  • Under the property column, go to Data Streams
  • Click the stream that is causing the issue
  • Make sure Enhanced measurement is enabled
  • Click the cog corresponding to Enhanced measurement
  • Show advanced settings in Page views and make sure that Page changes based on browser history events is checked
Using browser history events seems to be able to get past the use of AJAX not loading a new page when users navigate the full width tree view.

If you try this yourself, please let us know how it goes! We can potentially update the documentation if this solution seems viable. Thanks!

Cheers, 
 
Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him

gomes...@gmail.com

unread,
Jul 14, 2023, 2:47:50 PM7/14/23
to AtoM Users
Hello Dan,

Thank you for the reply.
The option 'Page changes based on browser history events' was not activated, so I have activated it. However, the problem still persists with the Full Width Treeview. The Sidebar Treeview is functioning correctly, but when using the Full Width Treeview, I need to press F5 (browser refresh) after clicking on a record for it to appear in GA (I am testing it with the GA real-time page)."

Dan Gillean

unread,
Jul 17, 2023, 10:02:06 AM7/17/23
to ica-ato...@googlegroups.com
Thanks for the feedback, Gomes. 

I've passed this information and a link to this thread on to our Maintainers. They said they will investigate the issue further, and provided the following initial response: 

Thanks for getting the feedback! That result totally makes sense... The fix should at least allow tracking to work for full width after 24hrs, but we will need to add some features to get full width tree view to be tracked in real-time. I'll add it to our backlog

Cheers,  

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him

Reply all
Reply to author
Forward
0 new messages