Here's my problem:

  • I have a static site with Google Analytics tracking code.
  • To buy one of my services, users call me, and when their order is ready (many days later), I send them an e-mail link to a special page (download.php) where I have GA tracking code that is executed the first time they visit, so I track a "sale".
  • The issue is, GA thinks that "sale" was a separate visit, and erroneously shows that only direct visits to my site result in sales. I don't understand how I can view stats (Pages / Visit, Avg. Time on Site, etc.) about users who eventually bought something.

I've tried events and e-commerce tracking with no luck. Please help!

Dani AI

Generated

Short answer: you can. Treat the emailed-download visit as the moment you record the conversion, but send that conversion to Google Analytics with the visitor identity or original source attached (server-side Measurement Protocol or a persistent user-level value). That keeps the purchase tied to the original user and enables you to report on their earlier sessions instead of having GA attribute the sale to a later “direct” visit. (developers.google.com)

Practical, low-friction workflow (works with GA4):

  1. Capture the GA client_id on first visit and store it server-side (cookie, CRM, DB). Example using gtag:
gtag('get','G-XXXXXXX','client_id', clientId => {
  fetch('/save-client', {method:'POST',body:JSON.stringify({client_id:clientId})});
});
  1. When the phone order becomes a sale, send a server POST to GA4 Measurement Protocol with that same client_id (include a unique transaction_id/event_id to dedupe). Minimal JSON example:
POST https://www.google-analytics.com/mp/collect?measurement_id=G-XXX&api_secret=SECRET
{
  "client_id":"123456789.1652295143",
  "events":[{"name":"purchase","params":{"transaction_id":"T12345","value":99.99,"currency":"USD"}}]
}

Test with GA4 DebugView and the MP validation endpoint. (developers.google.com)

If you cannot reliably capture client_id, persist the original acquisition info on the user (user-scoped custom dimension or user property: e.g., first_source / first_medium) at first touch and use that for later analysis and segments. That gives you reports showing behavior (pages/session, time on site, etc.) for purchasers grouped by first touch. ()

Caveats & checklist: include transaction_id/event_id to avoid double-counting; if you want the server event to inherit session/source, also pass session_id or traffic_source fields or timestamp_micros as needed; be mindful of attribution model differences (GA’s default attribution behavior can affect how credit appears in reports). Do not send PII to Google Analytics — follow Google’s policy. Validate thoroughly in DebugView / BigQuery if you need user-journey joins. ()

(Thanks to for the clear brief; is right that naive client-only tracking will show the email click as a separate direct session — the server-side or user-scoped approaches above are the usual solutions.)

Recommended Answers

All 9 Replies

Member Avatar for Member #949455

I've tried events and e-commerce tracking with no luck. Please help!

It really depends on what platform you are using and also where you put the code.

What platform do you mean? Isn't GA my platform? The site is custom coded.

Could you give some examples of platforms that could theoretically support this?

Member Avatar for Member #949455

What platform do you mean? Isn't GA my platform? The site is custom coded.

Platform mean e-commerece kinda like Prestashop or Magento those are called platform or someone create custom coded e-commerece would be much easier to add Google Analytics.

If you are gonna to put a Google Analytics on each page to track it then will will appear on Google Analytics.

Google Analytics is tracking visitors not to track with sales you need to create a separate code for your website.

Tracking sale you can look at your Payment plan (PayPal or etc).

Yes, I already know all this. Please look at my original question. Treating a specific page load as a conversion, but across visits, is my question. Not adding GA code.

Member Avatar for Member #949455

Please look at my original question. Treating a specific page load as a conversion, but across visits, is my question. Not adding GA code.

Google Analytics track visitors.

You want the sales appear on Google Analytics? Is that what you are asking?

Exactly, I want to treat a specific page load as a GA conversion. That page is being tracked by GA as is the rest of the site.

Unfortunately, that page load is often a separate visit since its an email link, which makes GA think conversions usually come from direct visits to that page, which is wrong.

Member Avatar for Member #949455

Exactly, I want to treat a specific page load as a GA conversion.

It's not gonna to appear on GA

Unfortunately, that page load is often a separate visit since its an email link, which makes GA think conversions usually come from direct visits to that page, which is wrong.

Correct, conversion on visit on that page is different when it redirect to the payment website.

You can't create a sale conversion on GA. It's a separate code it has nothing to do with GA.

It will count as a visit even though it's redirect.

I was afraid that might be the case :/ thanks for your responses.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.