I didn't success to integrate Google Analytics in Adobe Digital Publishing Suite.
What I done is create a dummy html file that include ga script as :
<!DOCTYPE html>
<html>
<body>
<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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXX-Y', { 'cookieDomain': 'none' });
ga('send', 'pageview');
</script>
</body>
</html>
If I try on my localhost, I can see the page on the live google analytics, but if a make a html object on DPS, export it, I can see my white page but not the live stats in GA.
Is that someone success to do it and how ?
Did you embed the html in the app/magazine?
If this is the case, the webview probably adds file: before the url of the GA javascript file (so it can not be found). You can manually add https: to prevent this.
Your code should be like this:
(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-XXXX-Y', { 'cookieDomain': 'none' });
ga('send', 'pageview');
Related
We have an tracking issue when our page is iframed.
Basically, we have a website: https://www.ourwebsite.com
Our website contains the following code in the head section:
(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', {
trackingId: "UA-FOOBAR-1",
cookieDomain: 'auto',
tenantCode: "someString"
});
ga('send', 'pageview');
This works fine, and I see a corresponding request to https://www.google-analytics.com/j/collect when the page load:
Screenshot of Chrome Network Tab
However, when this same page is in an iframe:
<iframe id="iframe" src="https://www.ourwebsite.com" scrolling="no" style="width: 100% !important; min-width: 100% !important; overflow: hidden;"></iframe>
The request to the google analytics /collect endpoint is missing from the Chrome Network Tab, and we do not see the pageview event in the browser.
If the iframe src is changed from https to http, I start seeing reqeusts to /collect again.
The parent document is using the same scheme as the iframe (uses https when the iframe uses https, and uses http when the iframe is on http)
Full page source of ourwebsite.com:
<!DOCTYPE html>
<html lang="en">
<head>
<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', {
trackingId: "UA-FOOBAR-1",
cookieDomain: 'auto',
tenantCode: "someString"
});
ga('send', 'pageview');
</script>
</head>
<body class="ui-mobile">
</body>
</html>
I am trying to send an event (with a numeric value) to google analytics but the numeric value is not being shown in google analytics dashboard:
<!-- Google Analytics -->
<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', 'XX-XXXXX-X', 'auto');
ga('send', 'pageview');
ga('send', {
hitType: 'event',
eventCategory: 'test',
eventAction: 'visit_on_page',
eventLabel: 'label2',
eventValue: Math.round(Math.random()*100)
});
You can find event value in Events report (not in Real time report).
I have two sites:
example-1.com
example-2.com
I need to have one analitycs (UA-XXXXXXXX-2) only for page example-1.com.
However I also need GA (UA-XXXXXXXX-1) which will be implemented on both sites. Is this code ok for that?
I want to implement it only to site example-1.com ; site example-2.com has only one analiytics so it is done via GTM (with allow linker also).
<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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-1', 'auto', {'allowLinker': true}, {name: 'First'});
ga('First.require', 'linker');
ga('linker:autoLink', ['example-1.com', 'example-2.com'] );
ga('First.require', 'displayfeatures');
ga('First.send', 'pageview');
ga('create', 'UA-XXXXXXXX-2', {name: 'Second'});
ga('Second.require', 'displayfeatures');
ga('Second.send', 'pageview');
</script>
Trying to setup dynamic remarketing. Analytics and Adwords are linked and in use for some time now.
I modified the Analytics tag to require displayfeatures and set customer dimensions. I also added an extra event and pageview tag for testing purposes.
However, in adwords I get the message "We haven't detected the Google Analytics remarketing functionality on your website."
Below are the tags currently active on the site:
<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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'XX-00000000-0', 'auto');
ga('require', 'displayfeatures');
ga('set', 'dimension1', 'FOOBAR1, FOOBAR2, FOOBAR3');
ga('set', 'dimension2', 'home');
ga('set', 'dimension3', '44.44, 55.55, 66.66');
ga('send', 'pageview');
</script>
<script type="text/javascript">
ga('send', 'event', 'product', 'view', {
'dimension1': 'FOOBAR4, FOOBAR5, FOOBAR6',
'dimension2': 'product',
'dimension3': '77.77, 88.88, 99.99'
});
</script>
<script type="text/javascript">
ga('send', 'pageview', {
'dimension1':'FOOBAR7, FOOBAR8, FOOBAR9',
'dimension2':'cart',
'dimension3':'11.11, 22.22, 33.33',
});
</script>
I had the same issue and brought on our Adwords rep to help mediate between GA. They claimed it may have something to do with the CMS, but nonetheless asked to try it out with Google Tag Manager.
Tried Google Tag Manager and the problem went away.
My code is using the new Universal GA code, with ga(send syntax, as follows:
<td id="newevent" onclick="ga('send', 'search-result', 'click', 'EVENTNAME');" ></td>.
I am using the Universal GA JS code in my section.
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Google Analytics -->
<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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXX-A');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
</head>
<body>
TEST
</body>
</html>
However, no event hits are registered in the GA Dashboard. Please advise.
I think you have made a small mistake in your cording. See you are sending the message, but with out saying what is executing. You are missing “event” part in your code
New Code :
ga('send', 'event', 'search-result', 'click', 'EVENTNAME');