Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add segment.io JS snippet for more analytic options #1690

Merged
merged 1 commit into from
Oct 30, 2017

Conversation

robbkidd
Copy link
Contributor

Optionally included when a Segment write key is set in the environment.
Disabled altogether if airgapped.

Renamed the _google_analytics partial so that it can collect whatever
other client-side analytics that may be added in the future.

Closes #1689

Optionally included when a Segment write key is set in the environment.
Disabled altogether if airgapped.

Renamed the _google_analytics partial so that it can collect whatever
other client-side analytics that may be added in the future.

Signed-off-by: Robb Kidd <rkidd@chef.io>
@robbkidd robbkidd requested a review from a team October 25, 2017 16:38
@robbkidd
Copy link
Contributor Author

With SEGMENT_WRITE_KEY=justtestingdontmindme

Results in:

<script type="text/javascript" async="" src="http://cdn.segment.com/analytics.js/v1/justtestingdontmindme/analytics.min.js"></script>
<script>
  !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","debug","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="4.0.0";
  analytics.load("justtestingdontmindme");
  analytics.page();
    }}();
</script>

Copy link

@TrevorBramble TrevorBramble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hamburglar asked @chef/cia to take a look and... looks good to me?

@robbkidd
Copy link
Contributor Author

It's probably fine.

@iennae I reckon we're approved for launch.

@robbkidd robbkidd merged commit f193075 into master Oct 30, 2017
@robbkidd robbkidd deleted the robb/add-segment-analytics branch October 30, 2017 15:31
@tas50 tas50 added Type: Enhancement Adds new functionality. and removed Enhancement labels Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Adds new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants