diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index cb8cab1c3..5d0612fde 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -5061,6 +5061,11 @@ "integrity": "sha1-8OgK4DmkvWVLXygfyT8EqRSn/M4=", "dev": true }, + "js-cookie": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.1.4.tgz", + "integrity": "sha1-2k7FA4ZvFJ0WTPJfV57zEBUCXY0=" + }, "js-stringify": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz", diff --git a/package.json b/package.json index e12432a87..8b9dfd8c6 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "history": "^1.17.0", "html5-uploader": "^0.1.1", "isomorphic-fetch": "^2.2.1", + "js-cookie": "^2.1.4", "linkify-it": "^2.0.3", "lodash": "^4.16.4", "moment": "^2.14.1", diff --git a/src/config/constants.js b/src/config/constants.js index 7d16d77a2..120a32549 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -260,4 +260,8 @@ export const LS_INCOMPLETE_PROJECT = 'incompleteProject' export const CONNECT_MESSAGE_API_URL = process.env.CONNECT_MESSAGE_API_URL || TC_API_URL -export const NEW_PROJECT_PATH = '/new-project' \ No newline at end of file +export const NEW_PROJECT_PATH = '/new-project' + +// Analytics constants +export const GA_CLICK_ID = '_gclid' +export const GA_CLIENT_ID = '_gacid' \ No newline at end of file diff --git a/src/projects/create/containers/CreateContainer.jsx b/src/projects/create/containers/CreateContainer.jsx index 18cd551c5..02a0b7a2b 100644 --- a/src/projects/create/containers/CreateContainer.jsx +++ b/src/projects/create/containers/CreateContainer.jsx @@ -1,4 +1,5 @@ import _ from 'lodash' +import Cookies from 'js-cookie' import React, { PropTypes } from 'react' import { withRouter, browserHistory } from 'react-router' import { connect } from 'react-redux' @@ -13,7 +14,9 @@ import { LS_INCOMPLETE_PROJECT, PROJECT_STATUS_IN_REVIEW, ACCOUNTS_APP_REGISTER_URL, - NEW_PROJECT_PATH + NEW_PROJECT_PATH, + GA_CLIENT_ID, + GA_CLICK_ID } from '../../../config/constants' const page404 = compose( @@ -131,6 +134,14 @@ class CreateConainer extends React.Component { // if user is logged in and has a valid role, create project // uses dirtyProject from the state as it has the latest changes from the user // this.props.createProjectAction(project) + const gaClickId = Cookies.get(GA_CLICK_ID) + const gaClientId = Cookies.get(GA_CLIENT_ID) + if(gaClientId || gaClickId) { + const googleAnalytics = {} + googleAnalytics[GA_CLICK_ID] = gaClickId + googleAnalytics[GA_CLIENT_ID] = gaClientId + _.set(project, 'details.utm.google', googleAnalytics) + } this.props.createProjectAction(project, PROJECT_STATUS_IN_REVIEW) } else { // redirect to registration/login page