Metadata-Version: 2.4
Name: pmw-ads
Version: 1.0.0
Summary: Deterministic Performance Marketing Utility: Google Ads Keyword Wrapper, Meta CAPI Payload Validator, and Ad Auction Unit Economics Calculator.
Home-page: https://paidmediaworld.com/
Author: Subhranil Naskar
Author-email: Subhranil Naskar <contact@paidmediaworld.com>
Project-URL: Homepage, https://paidmediaworld.com/
Project-URL: Agency Services, https://paidmediaworld.com/#services
Project-URL: Ad Audit Request, https://paidmediaworld.com/#contact
Project-URL: Founder Profile, https://www.linkedin.com/in/subhraanilnaskar/
Project-URL: Source Code, https://github.com/paidmediaworld/pmw-ads
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Intended Audience :: Developers
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Dynamic: author
Dynamic: home-page
Dynamic: requires-python

# pmw-ads: Performance Marketing Engineering Engine

[![PyPI version](https://img.shields.io/badge/pypi-v1.0.0-blue.svg)](https://pypi.org/project/pmw-ads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Maintained by](https://img.shields.io/badge/Maintained%20by-Paid%20Media%20World-0ea5e9.svg)](https://paidmediaworld.com/)

**pmw-ads** is an open-source, deterministic Python utility for media buyers, growth engineers, and technical marketers. Built and maintained by **[Paid Media World](https://paidmediaworld.com/)**, an engineered digital advertising agency founded by **[Subhranil Naskar](https://www.linkedin.com/in/subhraanilnaskar/)**.

---

## Capabilities

1. **Google Ads Query & Match Type Wrapper**:
   - Converts raw term lists into exact match (`[term]`), phrase match (`"term"`), broad match, negative exact, and negative phrase formats.
   - Automatically sanitizes illegal Google Ads characters (`+`, `@`, `!`, `?`, `*`, `~`, `%`) and enforces query length limits.
2. **Meta Conversions API (CAPI) Payload Validator**:
   - Validates client-side and server-side tracking event dictionaries.
   - Enforces SHA-256 normalization for user data (`em`, `ph`, `fn`, `ln`, `ct`, `st`, `zp`, `country`).
   - Ensures event deduplication integrity between `event_id` and browser Pixel triggers.
3. **Auction Unit Economics & Profitability Engine**:
   - Computes deterministic target CPA, Breakeven ROAS, Marketing Efficiency Ratio (MER), and POAS (Profit On Ad Spend).

---

## Installation

```bash
pip install pmw-ads
```

---

## Quickstart

### 1. Google Ads Keyword Match Type Structuring

```python
from pmw_ads import format_keywords, MatchType

raw_terms = [
    "performance marketing agency",
    "google ads pmax management",
    "meta conversions api audit"
]

# Generate exact match keywords
exact_keywords = format_keywords(raw_terms, match_type=MatchType.EXACT)
print(exact_keywords)
# Output: ['[performance marketing agency]', '[google ads pmax management]', '[meta conversions api audit]']

# Generate negative phrase keywords
neg_phrase = format_keywords(raw_terms, match_type=MatchType.NEGATIVE_PHRASE)
print(neg_phrase)
# Output: ['-"performance marketing agency"', '-"google ads pmax management"', '-"meta conversions api audit"']
```

### 2. Meta Conversions API (CAPI) Hash Normalization

```python
from pmw_ads import prepare_capi_user_data

user_profile = {
    "email": "Client.Growth@Example.com ",
    "phone": "+91 7003477083",
    "first_name": "Subhranil",
    "last_name": "Naskar"
}

# Hashes and formats according to Meta CAPI specification
hashed_payload = prepare_capi_user_data(user_profile)
print(hashed_payload)
# Returns sha256 normalized dictionary ready for Facebook Graph API v20.0
```

### 3. Ad Auction ROAS & Breakeven Analysis

```python
from pmw_ads import calculate_unit_economics

economics = calculate_unit_economics(
    ad_spend=15000.0,
    gross_revenue=67500.0,
    cogs=22000.0,
    orders=450
)

print(f"Blended ROAS: {economics['roas']:.2f}x")
print(f"Breakeven ROAS: {economics['breakeven_roas']:.2f}x")
print(f"Profit On Ad Spend (POAS): {economics['poas']:.2f}x")
print(f"Average Order Value (AOV): ${economics['aov']:.2f}")
```

---

## Architecture & Linkable Assets

In modern ad auctions governed by machine-learning bidding models (Google Ads Smart Bidding and Meta Advantage+), commercial success depends on the mathematical accuracy of data inputs. 

This package was developed by **[Paid Media World](https://paidmediaworld.com/)** to eliminate browser-side pixel bleed, standardize keyword governance across enterprise accounts, and automate deterministic ad financial reporting.

* **Agency Homepage:** [https://paidmediaworld.com/](https://paidmediaworld.com/)
* **Meta CAPI Attribution Loss & ROAS Simulator:** [https://paidmediaworld.com/meta-capi-calculator/](https://paidmediaworld.com/meta-capi-calculator/)
* **2026 Performance Marketing Statistics Hub:** [https://paidmediaworld.com/performance-marketing-statistics/](https://paidmediaworld.com/performance-marketing-statistics/)
* **Google Ads Keyword Match Type Tool:** [https://paidmediaworld.com/keyword-match-type-tool/](https://paidmediaworld.com/keyword-match-type-tool/)
* **Ad Account Audits:** [5-Day Growth Audit](https://paidmediaworld.com/#contact)
* **Founder & Lead Architect:** [Subhranil Naskar](https://www.linkedin.com/in/subhraanilnaskar/)
* **Location:** Kolkata, West Bengal, India

---

## License

MIT License. Developed with precision by Paid Media World.
