New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

optimizely-location

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimizely-location

Use Optimizely to determine site-visitor geolocation

latest
npmnpm
Version
0.0.3
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Optimizely Location

Unlike the rest of the Optimizely data object, optimizely.data.visitor.location is not immediately ready when the Optimizely page snippet has loaded since it has to fetch the data from a 3rd party.

Setup

Before this script can work, there needs to be an Optimizely experiment with a geo-targeted audience condition running on your site.

  • Create an Optimizely experiment using your site's URL
  • Add an audience with a Location condition
  • Change the URL Targeting setting to null
  • Save and start the experiment

Note, by setting the URL Targeting to null, you are ensuring that the experiment will not use any of your Optimizely monthly uniques.

You can check to see if location is now enabled by inspecting element on your site and typing the following into the Console:

window.optimizely.data.visitor.location

This should return an object with location data. If it is null, please ensure that you have followed the above steps correctly.

Usage

Install from npm, or add optimizely-location.js after your Optimizely snippet

npm install optimizely-location --save

This script assigns a Promise called optimizelyLocation to the global scope that will resolve when the user's location is ready. If you installed from npm, import the script:

import optimizelyLocation from 'optimizely-location';

Then wrap your location-based code in the Promise .then() syntax

window.optimizelyLocation.then((res) => {
  // your user-location based code, eg:
  console.log(res); // will log something like {continent: "NA", country: "US", region: "CA", city: "SANFRANCISCO"}
});

This promise will try to find the user location in intervals of 100 milliseconds for 2 seconds before rejecting.

FAQs

Package last updated on 29 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts