Skip to content

Correct way to send event scoped custom dimension #477

@AltamashShaikh

Description

@AltamashShaikh

Hello,

I wanted to confirm if this is the correct way to send event scoped dimensions ?

 tracker = MatomoTracker(siteId: "23",
                                baseURL: URL(string: "https://your-matomo.example/matomo.php")!)

    // Optional: VISIT-level dimension (applies to all hits after you set it)
    // (Only if your SDK version exposes this API)
    // tracker.set(value: "paid_user", forIndex: 1)

    // EVENT-level custom dimension(s): attach only to THIS event
    let eventDims: [CustomDimension] = [
        CustomDimension(id: 3, value: "black_friday"),   // Event-scope dimension #3
        CustomDimension(id: 4, value: "cta_primary")     // Event-scope dimension #4
    ]

    let event = Event(
        tracker: tracker,
        action: ["shop", "pricing"],                     // action_name path
        url: URL(string: "myapp://shop/pricing"),
        eventCategory: "ui",
        eventAction: "tap",
        eventName: "upgrade_button",
        eventValue: nil,
        customTrackingParameters: [
            // Any extra Tracking API params that aren’t first-class properties
            "pv_id": UUID().uuidString
        ],
        dimensions: eventDims,
        variables: [],
        isCustomAction: false
    )

    tracker.track(event)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions