{"id":13667751,"url":"https://github.com/aws-samples/aws-serverless-tracking-pixel","last_synced_at":"2025-04-26T18:30:33.207Z","repository":{"id":39490182,"uuid":"315749466","full_name":"aws-samples/aws-serverless-tracking-pixel","owner":"aws-samples","description":"This solution deploys a lambda function and an API Gateway HTTP API to process tracking information from the HTTP request, returning a 1x1 transparent pixel so it can be invoked from an IMG HTML tag. The processing AWS Lambda Function sends the parsed information to an Amazon Kinesis Data Firehose Stream that should already exist. This solution is created as a baseline to be modified so it adapts to the specific use-case, according to the incoming information that should be processed.","archived":false,"fork":false,"pushed_at":"2021-09-01T10:40:36.000Z","size":20,"stargazers_count":24,"open_issues_count":1,"forks_count":12,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-11T03:33:21.482Z","etag":null,"topics":["serverless-beacon-server","tracking-pixel"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aws-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-24T20:51:19.000Z","updated_at":"2023-11-19T06:58:56.000Z","dependencies_parsed_at":"2022-08-09T14:49:29.510Z","dependency_job_id":null,"html_url":"https://github.com/aws-samples/aws-serverless-tracking-pixel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Faws-serverless-tracking-pixel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Faws-serverless-tracking-pixel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Faws-serverless-tracking-pixel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Faws-serverless-tracking-pixel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aws-samples","download_url":"https://codeload.github.com/aws-samples/aws-serverless-tracking-pixel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251035092,"owners_count":21526303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["serverless-beacon-server","tracking-pixel"],"created_at":"2024-08-02T07:00:48.906Z","updated_at":"2025-04-26T18:30:32.900Z","avatar_url":"https://github.com/aws-samples.png","language":"Python","funding_links":[],"categories":["Python","AWS Serverless Architectures"],"sub_categories":[],"readme":"# aws-serverless-tracking-pixel\n\nThis solution deploys a lambda function and an API Gateway HTTP API to process tracking information from the HTTP request, returning a 1x1 transparent pixel so it can be invoked from an IMG HTML tag.\nThe processing AWS Lambda Function sends the parsed information to an Amazon Kinesis Data Firehose Stream that should already exist.\nThis solution is created as a baseline to be modified so it adapts to the specific use-case, according to the incoming information that should be processed.\n\n## Solution architecture\n\nThe solution is built on top of serverless components\n\n![](ArchitectureDiagram.png)\n\n## Deploying the solution\n\nThis project is built using the AWS Serverless Application Model (SAM), a framework extending AWS CloudFormation syntax to easily define serverless components such as AWS Lambda functions or Amazon DynamoDB tables.\n\nThe following tools are required to deploy it:\n\n* [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)\n* [Python 3](https://www.python.org/downloads/)\n* [Docker](https://hub.docker.com/search/?type=edition\u0026offering=community)\n\nThe following resources act as a prerequisit:\n* Amazon Kinesis DataFirehose delivery stream: A delivery stream should already exist in the same account and the same region where the solution will be deployed\n\nTo build and deploy for the first time, run the following in your shell:\n\n```bash\nsam build --use-container\nsam deploy --guided\n```\n\nThe first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts. If you choose to save your choices to `samconfig.toml`, then you no longer will need to pass the `--guided` flag, as the SAM CLI will read your settings from it.\n\n### Template parameters\n* `KinesisFirehoseARN`: ARN of the Amazon Kinesis DataFirehose delivery stream where the processed information will be published to.\n* `KinesisFirehoseStreamName`: Stream name of the previous delivery stream.\n\n### Template output\n* `TrackingPixelProcessingAPIURL`: URL endpoint to send the tracking information to.\n\n## How to use\n\nThe Amazon Lambda Function code should be modified to parse the desired HTTP request information. The example implementation extracts 5 different fields:\n* `date`: Time field of the HTTP request context.\n* `ip`: x-forwarded-for field of the HTTP request context, as Amazon API Gateway will place the original requester IP in this field.\n* `userAgent`: user-agent field of the HTTP request context.\n* `userId`: Custom parameter expected on the query string, called 'userid'.\n* `thirdPartyId`: Custom parameter expected on the query string, called 'thirdpartyname'.\n\nOnce customized, you can directly begin tracking interactions from web pages or emails from an HTML IMG tag, or from any other event producer you might consider by generating HTTP-GET requests to the URL of the template output. As an example, this would be an HTTP call for the example implementation:\n\n```bash\nwget https://\u003cyour template output domain\u003e?userid=aws_user\u0026thirdpartyname=example.hightrafficwebsite.com”\n```\n\n## Developing\n\nYou can build with the following command:\n\n```bash\nsam build --use-container\n```\n\nThe function can be locally invoked using `sam local invoke`. The `events` directory contains test events that can be passed on the function invocation.\n\n```bash\nsam local invoke TrackingPixelProcessing --event events/event.json\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-samples%2Faws-serverless-tracking-pixel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faws-samples%2Faws-serverless-tracking-pixel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-samples%2Faws-serverless-tracking-pixel/lists"}