Coder Social home page Coder Social logo

Comments (5)

dominykas avatar dominykas commented on August 16, 2024

One more alternative would be to keep universal-analytics as a "raw", "close to the metal" library and send all the relevant ecommerce params via options object (use standard validation logic, with extensions in a similar way to custom dimensions implementation) and build a new library to construct these params...

from universal-analytics.

alessbell avatar alessbell commented on August 16, 2024

@dominykas Hi Dominykas! We (https://github.com/breather) need enhanced ecommerce support too. Let me know how I can help!

from universal-analytics.

dominykas avatar dominykas commented on August 16, 2024

PR #29 is ready - it updates the acceptable params and also the validations, however it must be noted, that the lib DOES support all the EE params, except that without my PR it will give warnings if debug flag is set to true.

I also published a gampee module to help with constructing EE params (I'll update and document it further), but here's some sample code how to use it:

var gampee = require("gampee"),
    ga = require("universal-analytics"),
    _ = require("lodash");


var ecommerceParams = gampee([
    {
        // visitor saw two products in search
        "type": "impression",
        "list": "search",
        "products": [
            { "id": "shirtM", "name": "Nice T-Shirt (M)", "position": 1 },
            { "id": "shirtXL", "name": "Nice T-Shirt (XL)", "position": 2 }
        ],
        "currency": "EUR"
    },
    {
        // visitor saw one product in highlights
        "type": "impression",
        "list": "highlights",
        "products": [
            { "id": "pants", "name": "Pretty Pants" }
        ],
        "currency": "EUR"
    },
    {
        // and added one 5 of shirtM to cart
        "type": "add",
        "products": [
            { "id": "shirtM", "name": "Nice T-Shirt (M)", "position": 1, "quantity": 5 }
        ],
        "currency": "EUR"
    }
]);

var ua = ga("UA-00000000-0", "5bbb81ff-0757-44e0-8fcb-f263d982b95a", { debug: true });
ua.pageview(_.merge({
    dp: "/",
    cd20: "one",
    cm20: "two"
}, ecommerceParams));

Result:

[universal-analytics] Enqueued pageview ({"dp":"/","cd20":"one","cm20":"two","il1nm":"search","cu":"EUR","il1pi1id":"shirtM","il1pi1nm":"Nice T-Shirt (M)","il1pi1ps":"1","il1pi2id":"shirtXL","il1pi2nm":"Nice T-Shirt (XL)","il1pi2ps":"2","il2nm":"highlights","il2pi1id":"pants","il2pi1nm":"Pretty Pants","pa":"add","pal":"search","pr1id":"shirtM","pr1nm":"Nice T-Shirt (M)","pr1ps":"1","pr1qt":"5","v":"1","tid":"UA-00000000-0","cid":"5bbb81ff-0757-44e0-8fcb-f263d982b95a","t":"pageview"})

from universal-analytics.

amit034 avatar amit034 commented on August 16, 2024

tried this sample code got :
[universal-analytics] Warning! Unsupported tracking parameter il1nm (search)
[universal-analytics] Warning! Unsupported tracking parameter il1pi1id (shirtM)
[universal-analytics] Warning! Unsupported tracking parameter il1pi1nm (Nice T-Shirt (M))
[universal-analytics] Warning! Unsupported tracking parameter il1pi1ps (1)
[universal-analytics] Warning! Unsupported tracking parameter il1pi2id (shirtXL)
[universal-analytics] Warning! Unsupported tracking parameter il1pi2nm (Nice T-Shirt (XL))
[universal-analytics] Warning! Unsupported tracking parameter il1pi2ps (2)
[universal-analytics] Enqueued pageview ({"dp":"/search?q=some+product","cd20":"one","cm20":"two","il1nm":"search","cu":"EUR","il1pi1id":"shirtM","il1pi1nm":"Nice T-Shirt (M)","il1pi1ps":"1","il1pi2id":"shirtXL","il1pi2nm":"Nice T-Shirt (XL)","il1pi2ps":"2","v":"1","tid":"UA-62992924-1","cid":"5bbb81ff-0757-44e0-8fcb-f263d982b95a","t":"pageview"})

and no impression under conversation -> ecommerce -> overview

from universal-analytics.

dominykas avatar dominykas commented on August 16, 2024

The warnings are because the PR is still not merged.

As for impressions - just to double check - you know there's a delay until the stats display, right? Did the "add to cart" appear?

from universal-analytics.

Related Issues (20)

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.