I want to send the custom name of the link clicked by user.
Iam using the following code
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22140531-1']);
_gaq.push(['_setCustomVar',1,'landline','acct_Summary',2]);
_gaq.push(['_trackEvent','Telemedia','bill_guide']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +
'.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script
Is the above script correct for what iam trying to do??
Also how will i see these custom values in the GA account??
Anyone please help as iam stuck badly in my project due to this.
Related
I want to configure an event parameter that will be sent automatically with every event I send to GA4.
Including the page_view event and all other "Automatically collected events".
This is my setup configuration:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
// Doesn't work!!
gtag('set', {
'parameter_key': 'parameter_value'
});
gtag('config', 'G-XXXXXXXX');
</script>
When I'm using the set command, the param_key event parameter is not sent with any event. It's totally ignored.
However, when I move this object into the config command, it does work:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
// Works!
gtag('config', 'G-XXXXXXXX', {
'parameter_key': 'parameter_value'
});
</script>
I want to use the set command because I have multiple properties, and I want this parameter to be used for all properties.
Anybody knows why it's not working and how to make it work?
Thanks!
<script async src="https://www.googletagmanager.com/gtag/js?id={{ $account_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'XXXXX');
</script>
here gtag('config', 'XXXXX'); and $account_id can be same of different?
They have to be the same but you can add other config row with different Property ID (note: the value is Property ID, not Account ID) to send hits simultaneously to several properties.
My website is static pages.
Using this gtag.js:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-measurementid"></script>
<script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-measurementid'); </script>
Under Admin I turned off the Enhanced Measurement setting "File Downloads" to allow for my custom event.
Using this event handler:
Print this page
But at analytics.google.com my custom event doesn't show. Both Realtime and in next day's report.
You can use this syntax:
gtag('event', 'login', {
'method': 'Google'
});
https://developers.google.com/analytics/devguides/collection/ga4/events
i have site1 and site2...
in the site1:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-хххх"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-ххх', {
'linker': {
'domains': ['site1', 'site2']
}
});
</script>
in the site2:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-хххх"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-ххх', {
'linker': {
'domains': ['site1', 'site2']
}
});
</script>
site1: source domain
site2: destination domain
I have two sessions displayed
displays: This hit starts a new session, most likely because the client ID changed. This is caused by an improper tracking code implementation.
what could be the problem?
You need to add site2 to "Referral Exclusion List" in Google Analytics account for these sites.
Property Settings --> Tracking Info --> Referral Exclusion List
In jspx file I have js script for tracking sign in providers (user are signing in by email, facebook or twitter).
var statsAnalytics = "${jndiSettings['statsAnalytics']}";
var _gaq = _gaq || [];
_gaq.push(['_setAccount', statsAnalytics]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
var providerId = '${providerId}';
if (providerId) {
_gaq.push(['_trackEvent', 'Sign in', providerId, 'Signed in with ' + providerId]);
}
After debugging with GA debugger for Chrome I'm getting:
_gaq.push processing "_setAccount" for args: "[UA-xxxxxxx-x]": [VM] ga_debug.js (9935):24
_gaq.push processing "_trackPageview" for args: "[]": [VM] ga_debug.js (9935):24
Track Pageview [VM] ga_debug.js (9935):24
_gaq.push processing "_trackEvent" for args: "[Sign in,facebook,Signed in with facebook]": [VM] ga_debug.js (9935):24
Track Event
Why doesn't my script send tracking beacons?
I disabled blocking adds with AddBlock and now it works!