I'm upgrading old google analytics code (ga) to latest gtag implementations.
in the old implementation we were using couple of site under one account using below command,
ga('create', '<TrackingID>', '<DomainName>');
but in the new implementation we are required to use
gtag('config', '<TrackingID>');
I managed to get google tracking working using the provided code by google, but I had to create two properties with different urls,
Is there a way to record analytics from both sites under same property.
Also in the old implementation we were able to push javascript function as below,
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<TrackingID>', '<Domain>']);
_gaq.push(['_trackPageview']);
_gaq.push(function () {
foo(1000);
});
Is there a way to push function using "gtag"?
Thanks
With gtag.js you can use following code:
gtag('config', 'GA_MEASUREMENT_ID', {
'linker': {
'domains': ['example.com']
}
});
https://developers.google.com/analytics/devguides/collection/gtagjs/cross-domain