Coder Social home page Coder Social logo

goatandsheep / aws-web-analytics Goto Github PK

View Code? Open in Web Editor NEW
48.0 4.0 1.0 925 KB

Privacy-focused alternative to Google Analytics on AWS Pinpoint

Home Page: https://console.aws.amazon.com/pinpoint/home

License: GNU General Public License v3.0

JavaScript 80.24% HTML 19.76%
amplify-js aws analytics google-analytics help-wanted

aws-web-analytics's Introduction

AWS Web Analytics

Tracking tag library for AWS Pinpoint as an alternative to Google Analytics using AWS Amplify.

Philosophy

Moving to AWS from Google Analytics is a way to maintain your users' privacy. Our blog post, Why you need to move off Google Analytics, explains more about it.

Amplify requires a lot of boilerplate to be able to setup a useful Analytics setup quickly and effectively.

Initialize your account

  1. Create an AWS account
  2. Create your Pinpoint account and Cognito Federated user pool
  3. Add the following tag to your code (with your own values for data-id-pool and data-pinpoint-id):
<script
    data-id-pool="us-east-1:abcd1234-abcd-1234-5678-abcd12345678"
    data-pinpoint-id="1234abcd5678abcd7890abcd1234"
    id="aws-web-analytics"
    src="https://goatandsheep.github.io/aws-web-analytics/dist/aws-web-analytics.js"
    type="text/javascript"
></script>

Click Events

Based on Amplify Page Event Tracking

Use data-aws-analytics- to indicate:

  • on: event listening
  • name: what will analytics event be named?
  • attrs: any needed associated info
<!-- you want to track this button and send an event when it is clicked -->
<button
    data-aws-analytics-on="click"
    data-aws-analytics-name="submitButtonClick"
    data-aws-analytics-attrs="attr1:attr1_value,attr2:attr2_value"
>Continue</button>

If you need other events than click, open a ticket

Custom events

Based on Amplify Analytics record.

window.Amplify.Analytics.record({
    name: 'albumVisit', 
    // Attribute values must be strings
    attributes: { genre: '', artist: '' }
});

AWS Cloud setup

IAM Role

Setup the Federated Cognito pool allowing unauth roles with the following permissions:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "mobiletargeting:PutEvents",
                "mobiletargeting:UpdateEndpoint"
            ],
            "Resource": "arn:aws:mobiletargeting:us-east-1:<account-number>:apps/<pinpoint-project-id>/*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "mobiletargeting:GetUserEndpoints",
                "mobileanalytics:PutEvents"
            ],
            "Resource": "*"
        }
    ]
}

CloudFormation coming soon...

aws-web-analytics's People

Contributors

bakztfuture avatar busynest avatar dependabot-preview[bot] avatar dependabot[bot] avatar goatandsheep avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

busynest

aws-web-analytics's Issues

Documentation, README could use more detail on setting up AWS Amplify

I was thinking it might be worth creating a "walk through" of setting it up in AWS. Although using the library is as simple as putting in a CDN based tracking code, I believe the bulk of the work for setting up this library happens on the AWS side.

At minimum, it would be good to at least include a direct link to the pinpoint product right in the README file.

I've attached screenshots of the process that might be helpful to include in the README or documentation, even as a background, not necessarily the main instructions.

Generic "where to click" style screenshots:
image

image

This screen was particularly confusing:
image
AWS is giving alternative instructions, takes mental work to figure out which steps to include and which steps to ignore in order to use this library instead.

Also, I would change include a nice dashboard style screenshot in the README file as well, just to show people what's possible with AWS too:
image

Cross origin errors

I setup pinpoint where the Identifies receive the following role:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "mobiletargeting:PutEvents",
                "mobiletargeting:UpdateEndpoint"
            ],
            "Resource": [
                "arn:aws:mobiletargeting:us-east-1:<aws-user-id>:apps/<pinpoint-id>/*",
            ]
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "mobileanalytics:PutEvents",
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor2",
            "Effect": "Allow",
            "Action": "mobiletargeting:GetUserEndpoints",
            "Resource": "arn:aws:mobiletargeting:us-east-1:<aws-user-id>:apps/<pinpoint-id>/*"
        }
    ]
}

However, I'm getting the following error:
image

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency @aws-amplify/core to v6
  • Update dependency webpack-dev-server to v5
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • @aws-amplify/analytics ^3.3.6
  • @aws-amplify/auth ^3.4.6
  • @aws-amplify/core ^3.6.0
  • babel-core ^6.26.3
  • babel-loader ^8.1.0
  • webpack ^4.46.0
  • webpack-cli ^3.3.12
  • webpack-dev-server ^3.11.0

  • Check this box to trigger a request for Renovate to run again on this repository

How can I build aws-web-analytics.js from source?

<script data-id-pool="us-east-1:abcd1234-abcd-1234-5678-abcd12345678" data-pinpoint-id="1234abcd5678abcd7890abcd1234" id="aws-web-analytics" src="https://goatandsheep.github.io/aws-web-analytics/dist/aws-web-analytics.js" type="text/javascript">

Hi I am not sure how to use the repo to build "aws-web-analytics.js".
Unfortunately I can't load external scripts in my environment. Is there any documentation on how to re-create the scripts? Is it identical to "aws-amplify.js" or?
Thanks.

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.