Segment.io `analytics.page` not sending to Google Analytics in Rails -


i'm following segment's quickstart guide at: https://segment.com/docs/libraries/analytics.js/quickstart/

basically, google analytics not receiving page views segment , can't figure out why...

in layouts/application file, have:

:javascript   !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["tracksubmit","trackclick","tracklink","trackform","pageview","identify","reset","group","track","ready","alias","page","once","off","on"];analytics.factory=function(t){return function(){var e=array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createelement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getelementsbytagname("script")[0];n.parentnode.insertbefore(e,n)};analytics.snippet_version="3.1.0";     analytics.load('#{env["segment_write_key"]}');     analytics.page();   }}(); 

other notes:

  • it pulling in write key environment variable
  • the integration set on segment dashboard (enabled, correct website tracking id supplied)
  • the analytics.load integration seems working because, in debugger console, analytics.integrations["google analytics"] initialized

page views are showing in segment dashboard's debugger page (with path, title, etc default properties set), views are not being transmitted google analytics.

i don't believe it's because arguments missing, because google's pageview requires either page or location property, both of supplied default through segment's page() method.

as turns out, had script loading same google analytics javascript file. have no idea why having duplicate script tag created issue, there is. removing duplicate fixed problem.

<script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script> <script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script> 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -