Git Product home page Git Product logo

analytics.js-integration-google-analytics's Introduction

analytics.js-integration-google-analytics's People

Contributors

bbeaird avatar brennan avatar carlosmecha avatar ccnixon avatar dominicbarnes avatar f2prateek avatar hankim813 avatar jlee9595 avatar ndhoule avatar peripheral1994 avatar segmentdestinationsbot avatar sperand-io avatar srthurman avatar wcjohnson11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

analytics.js-integration-google-analytics's Issues

support GA content groups

From @DirtyAnalytics on June 12, 2014 16:41

Here's the GA docs.

When these are set directly through GA the code looks like this:

ga('create', 'UA-XXXXXXXX-Y', 'example.com');
ga('set', 'contentGroup5', 'Docs');
ga('send', 'pageview');

And here's how I think it should work in Segment...

When people call this:

analytics.page({
  contentGrouping: 1,
  contentGroup: 'Men'
});

Becomes:

analytics.js: ga('set', 'contentGroup1', 'Men');

There are 5 content groupings slots available in GA, grouping is the very top level category, examples would be:

  • clothing
  • marketing
  • docs
  • app

Then there are content groups which the user defines as a string and for that reason there can be as many as they want, groups always fit under a content grouping, here are some examples that would fit in the groupings above:

  • shirts
  • case studies
  • integrations
  • settings

Let me know if this makes sense @ianstormtaylor @yields @calvinfo @lancejpollard

Also - let's only worry about supporting the GA universal tracking method.

Copied from original issue: segmentio/analytics.js-integrations#210

Equivalence of ga(set,...) in analytics.js ?

I am porting some ga code to use segment. There are the ga('set', .... ) calls for which I dont see a corresponding version in analytics.

It is not possible to pass in the custom dimensions as properties because they were being set in a different part of the page, and the track/page calls happen elsewhere.

What I am proposing is, we add a Analytics.prototype.set(props) method. The props would be buffered internally. And when users call track or page or identify, the api calls would be merged with those passed in with the set call. This way it would work for all integrations.

SPA sessions with referrer are broken

The problem

At YPlan, we found that using Segment on a Single Page Application is causing Google Analytics to break the sessions, giving us the wrong PPC vs Organic attributions.
The cause is that Segment is always sending the original referrer with the current (updated) url.

How to reproduce it

We created a simple SPA with React and React Router to reproduce the problem.

Landing on the application and clicking the links (i.e. updating the url) from a different referrer (e.g. jsfiddle) with the utm parameters results in a split session:

screen shot 2015-11-27 at 07 54 13

This is the "raw" Google Analytics data sent via Segment:

v:1
_v:j40
a:120322824
t:pageview
_s:1
dl:http://localhost:8000/?utm_source=michele&utm_medium=spa/
dr:http://fiddle.jshell.net/_display/
dp:/?utm_source=michele&utm_medium=spa/
ul:en-us
de:windows-1252
dt:Segment SPA
sd:24-bit
sr:1680x1050
vp:1123x332
je:1
fl:19.0 r0
_u:SCCAgAAj~
jid:
cid:1913804964.1439278034
tid:UA-32643507-4
v:1
_v:j40
a:120322824
t:pageview
_s:2
dl:http://localhost:8000/two
dr:http://fiddle.jshell.net/_display/
dp:/two
ul:en-us
de:windows-1252
dt:Segment SPA
sd:24-bit
sr:1680x1050
vp:1123x332
je:1
fl:19.0 r0
_u:SCCAgAAj~
jid:
cid:1913804964.1439278034
tid:UA-32643507-4
z:1688857593
v:1
_v:j40
a:120322824
t:pageview
_s:3
dl:http://localhost:8000/three
dr:http://fiddle.jshell.net/_display/
dp:/three
ul:en-us
de:windows-1252
dt:Segment SPA
sd:24-bit
sr:1680x1050
vp:1123x332
je:1
fl:19.0 r0
_u:SCCAgAAj~
jid:
cid:1913804964.1439278034
tid:UA-32643507-4
z:1714268981

Overriding the referrer

We read the documentation and we tried to override the referrer, as follows:

history.listen(() => {
  analytics.page('category', 'name', {
    referrer: 'https://www.itsarainysunnyday.com'
  });
});

But we found that Segment keeps on sending the original referrer to Google Analytics:

v:1
_v:j40d
a:2007255171
t:pageview
_s:1
dl:http://localhost:8080/
dr:http://fiddle.jshell.net/_display/
dp:/
ul:en-us
de:windows-1252
dt:category name
sd:24-bit
sr:1680x1050
vp:1676x216
je:1
fl:19.0 r0
_u:SCCAgAAj~
jid:
cid:2131063951.1440664624
tid:UA-32643507-4
z:1217894582

While it's sending the right one in the context:

path: "/"
referrer: "https://www.itsarainysunnyday.com"
search: ""
title: "Segment SPA"
url: "http://localhost:8080/"

Any suggestions?

useGoogleAmpClientId should be useAmpClientId

currently the ga creation with useGoogleAmpClientId set to true looks like this:

Running command: ga("create", "UA-81924801-3", {cookieDomain: "none", siteSpeedSampleRate: 1, sampleRate: 100, allowLinker: true, useGoogleAmpClientId: true})

GA debugger chrome tool throws the following warning:

Create config had an unknown parameter: "useGoogleAmpClientId"

Based on google's documentation on implementing AMP (https://support.google.com/analytics/answer/7486764), the field should be "useAmpClientId". Example from the docs:

ga('create', 'UA-XXXXX-Y', 'auto', {'useAmpClientId': true});

This results in different client ids being used for AMP vs non-AMP events, which results in two separate sessions.

Referrer override doesn't work

As per the GA doc, to override the referrer of a page (which defaults to document.referrer), one must use ga('set', 'referrer', new_referrer).

As per the Segment doc, this result can be obtained by passing properties to the page() call, as such: analytics.page({referrer: new_referrer})

However, this has no effect. The bug I believe comes from the fact that there is no .option('referrer', document.referrer) declared in the GA lib (https://github.com/segment-integrations/analytics.js-integration-google-analytics/blob/master/lib/index.js#L51), which causes the metrics() call to return nothing and doesn't issue a ga('set') call.

ability to set path in the track() method

From @TimmyCarbone on October 27, 2014 16:7

Currently, we can set the path property in the page() method and it sets GA's pagePath property.

It would be good for consistency to be able to set GA's pagePath in the track() method too.
We can set the path property but it won't affect GA's pagePath.

To summarize, the virtual path doesn't work on GA events. Currently, events and pageviews can't be associated through the path.

Should be something around there :
https://github.com/segmentio/analytics.js-integrations/blob/master/lib/google-analytics/index.js#L207

with a property like this :
https://github.com/segmentio/analytics.js-integrations/blob/master/lib/google-analytics/index.js#L173

Copied from original issue: segmentio/analytics.js-integrations#442

race condition on device mode...

... a customer has reported events missing from their google analytics reports and after lots of time investigating this i have reached the point of finding a race condition.

by refreshing a page a few times (it takes on average about 50 or so clicks, so dont give up too quick) i can see that :

ga.loaded
<true
ga.getAll()
<[]length: 0__proto__: Array(0)

normal expected network logs are:
image

when the race condition happens

image

manually creating the ga with a ga.create('UA-xxxx-1', 'auto') will flush the analytics queue and events get send ok.

segment calls all are ok in either case, so i suspect the "loaded" function does not work as it was designed to...

Test failures are breaking master

As noted in segmentio/analytics.js-integrations#645:

Google Analytics changed some internal implementation details and now our tests are failing, causing the entire project to fail. These tests don't actually indicate a failure of the integration, but rather an inappropriate intimacy problem in our tests.

Tests should be refactored to test the GA interface, not its internal mechanisms.

These tests are pretty much cosmetic right now but should be fixed as they could mask real errors

Google Analytics Integration extractCheckoutOptions bug, Impact Checkout Step Viewed and Completed

Base on the documentation:

https://segment.com/docs/spec/ecommerce/v2/#checkout-step-viewed
https://segment.com/docs/spec/ecommerce/v2/#checkout-step-completed

The checkout options are to be returned in this format:

analytics.track('Checkout Step Completed', {
  checkout_id: '50314b8e9bcf000000000000',
  step: 2,
  shipping_method: 'Fedex',
  payment_method: 'Visa'
});

However the Google Analytics Integration is coded to look for these value in that format

analytics.track('Checkout Step Completed', {
  checkout_id: '50314b8e9bcf000000000000',
  step: 2,
  shipping_method: 'Fedex',
  payment_method: 'Visa'
});

See code https://github.com/segment-integrations/analytics.js-integration-google-analytics/blob/master/lib/index.js#L903

function extractCheckoutOptions(props) {
  var options = [
    props.paymentMethod,
    props.shippingMethod
  ];
  // Remove all nulls, and join with commas.
  var valid = reject(options);
  return valid.length > 0 ? valid.join(', ') : null;
}

Install as a NPM module

Hey. We are using Webpack to bundle our JS files in our React project. For that reason i am using analytics.js directly from npm, and would like to install each integration from npm as well.

So would you mind publishing the integrations to npm?

GA not sending Completed Order as an event

From @gonegreen on May 3, 2014 19:17

I may be wrong here but it doesn't appear that GA sends the "Completed Order" track as an event. It correctly sends the ecommerce purchase but fails to actually send a standard event which requires the addition of another track() call with another event such as "Completed Purchase". Is this intentional or am I missing something?

All my transactions track in GA and all events are there but that one.

Copied from original issue: segmentio/analytics.js-integrations#134

Mixing Product Category and Event Category

When you set a Product category (example calling Product View) it also applies to the Event category.

Example:

analytics.track('Product Viewed', {
  name: 'Compton T-Shirt',
  sku: '9bdd2',
  price: 44.00,
  brand: 'Compton',
  category: 'T-Shirts',
  quantity: 1,
  currency: 'USD'
});

The expected analytics Event category is 'EnhancedEcommerce' but now both Event category and Product 1 category have value 'T-Shirt'.
image

Is there any way to separate the two categories?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.