New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

govuk_frontend_toolkit

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

govuk_frontend_toolkit - npm Package Compare versions

Comparing version 3.4.2 to 3.5.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

#3.5.0
- Adds cross domain tracking to Analytics API library: https://github.com/alphagov/govuk_frontend_toolkit/pull/185
#3.4.2

@@ -2,0 +6,0 @@

@@ -163,1 +163,13 @@ # Analytics

Pull `error-tracking.js` into your project, and initialise it after analytics (see [Create an analytics tracker, above](#create-an-analytics-tracker)), to track JavaScript errors.
## Tracking across domains
Once a Tracker instance has been created, tracking across domains can be set up
for pages like:
```js
GOVUK.analytics.addLinkedTrackerDomain(trackerIdHere, nameForTracker, domainToLinkTo);
```
Once this is done hits to that page will be tracked in both your local and the
named tracker, and sessions will persist to the other domain.

15

docs/javascript.md

@@ -92,13 +92,20 @@ ## JavaScript

1. Log in to Google Universal Analytics, select "UA - Preview environment".
1. Log in to Google Universal Analytics, select "UA - 1. GOV.UK(Entire Site - Filtered)".
2. In the left column, click on Behaviour, then Experiments and follow [these instructions](https://support.google.com/analytics/answer/1745152?hl=en-GB) to set up your experiment; you will need to have edit permissions on the Universal Analytics profile. If you cannot see a "Create experiment" button, this means you don't have these permissions; you can ask someone from the Performance Analyst team to set the experiment up for you.
3. In step number 2, in our case the address of the web pages will purely be used as descriptions in reports, so we recommend you pick the addresses accordingly, ie: "www.gov.uk" and "www.gov.uk/?=variation1".
4. In step number 3, "Setting up your experiment code", select "Manually insert the code" and make a note of the Experiment ID number located under the script window.
5. Add the below code to the page you want to test.
- the contentExperimentId is the Experiment ID you retrieved in step 3
- the contentExperimentId is the Experiment ID you retrieved in step 3.
- the variantId is 0 for the original variant, 1 for the first modified variant, 2 for the second modified variant, etc.
- see section above for other elements
- see section above for other elements.
This code requires analytics to be loaded in order to run; static is the app that would load the analytics by default, which automatically happens before experiments are run.
6. Check that it works: launch the app, open the page of your app, and check that there is a cookie with the name you had picked in your experiment. You can delete the cookie and refresh the page to check whether you can be assigned to another cohort.
6. Check that it works: launch the app, open the page of your app, and check that there is a cookie with the name you had picked in your experiment. You can delete the cookie and refresh the page to check whether you can be assigned to another cohort. Then in your browser console, go to the Networks tab and search for xid and xvar. The values should correspond to your contentExperimentId and the cohort your cookie indicates you were assigned to.
7. If it works, in Google Universal Analytics, click on "Next Step" and then "Start Experiment". You can ignore the error messages relative to Experiment Code Validation as they don't concern us in our setup.
```js

@@ -105,0 +112,0 @@ var test = new GOVUK.MultivariateTest({

@@ -92,2 +92,25 @@ (function() {

/*
https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain
trackerId - the UA account code to track the domain against
name - name for the tracker
domain - the domain to track
*/
GoogleAnalyticsUniversalTracker.prototype.addLinkedTrackerDomain = function(trackerId, name, domain) {
sendToGa('create',
trackerId,
'auto',
{'name': name});
// Load the plugin.
sendToGa('require', 'linker');
sendToGa(name + '.require', 'linker');
// Define which domains to autoLink.
sendToGa('linker:autoLink', [domain]);
sendToGa(name + '.linker:autoLink', [domain]);
sendToGa(name + '.set', 'anonymizeIp', true);
sendToGa(name + '.send', 'pageview');
};
// https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets

@@ -94,0 +117,0 @@ GoogleAnalyticsUniversalTracker.prototype.setDimension = function(index, value) {

@@ -49,3 +49,10 @@ (function() {

/*
Add a beacon to track a page in another GA account on another domain.
*/
Tracker.prototype.addLinkedTrackerDomain = function(trackerId, name, domain) {
this.universal.addLinkedTrackerDomain(trackerId, name, domain);
};
GOVUK.Tracker = Tracker;
})();
{
"name": "govuk_frontend_toolkit",
"version": "3.4.2",
"version": "3.5.0",
"description": "npm package for using the GOV.UK frontend toolkit",

@@ -5,0 +5,0 @@ "repository": {

@@ -1,1 +0,1 @@

3.4.2
3.5.0

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc