Sending additional data to Google Analytics from other php app - php

I have some problem to solve. Client was using third-party SaaS e-commerce platform (http://shoper.pl), which has integrated GA for E-Commerce. Everything works fine, except passing information about discounts. All transactions was showing on GA, but client needs to find, which transactions was made with discount code.
And there comes the biggest problem - as I said, thats SaaS platform, and code was closed.
We have created additional PHP app, for processing orders from Shoper, maybe there will be a option to 'inject' additional GA data this way? From app, we have access to all order data. Is that possible, to update some data on GA, basing on transaction ID? Or maybe you have some other solution for that?

Google Analytics has a data import feature, however the only import type that ties to a transaction id is refund data (which will not allow you to attach a discount code to the transaction). I would suggest a workaround, but can give no real guarantee that it will actually work (since data imports take a while to process this would take a long time to test).
Data imports need a key field within GA, with the same key in the data you want to import from an external source.
One of the data import types is "custom data". With that you can use a custom dimension as key. For that you need to create two custom dimensions - for examples sake I'll call them "key" and "coupon", both are hit scoped.
Next you have to set up a advanced filter in your view settings. If the request url matches the confirmation page you extract the transaction id and copy it (via "Output to constructor") to the custom dimension "key".
Next you go to property settings -> data import -> new data set -> type "custom data".
Give the data set a name, attach a view. In the data schema setting select "custom dimensions->key" as key field. In the imported data field select "custom dimensions->coupon" (as created above). Select "overwrite hit data". Download the data schema.
Prepare the data you want to import. In the data schema file fill the first column with the transaction ids. In the second column fill the rows with coupon code per transaction where applicable.
Go to your data import, click "manage uploads" and upload your file. Wait 24 hours until the data is processed. If things work as hoped the pageviews for the transactions will now have the custom dimension with the coupon id attached (if applicable, else it will simply be empty). I.e. the dimension will still not be tied to the transaction id, but at least to the pageview where the transaction took place, so that's the next best thing.
As I've said that's untested, but I do not see any particular reason why it wouldn't work, even if it's quite a roundabout way.

Related

How to prevent duplicate invoice in Quickbooks Online API?

I have been trying to integrate Quickbooks Online API with PHP in to my website and I have found an issue where I could keep on creating the same invoice.
Although there have been accepted answer in this forum however it is really being vague not exact.
"If you don't have the TxnID, there really isn't a way to detect a "duplicate" invoice in QuickBooks.Does this mean that upon creation of invoce there is no way to check if an invoice was already create via API?
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#create-an-invoice
When creating an invoice the values returned under "LinkedTxn" field is always empty
"The closest you can get is querying by RefNumber ...there's no guarantee that the invoice that you get back from that query is the invoice that you created."
Still same as first but I have been searching RefNumber under the documentation but I can't seem to find it.
If "RefNumber's" cannot be gauranteed then what are the other
alternatives?
Do I have to handle this on my local or at least add a column on my
local table for indicating if item is already sync?
PS: I also tried to insert txnid on the create invoice field however I wasn't successful.
While testing on sandbox I realized there is this number, what is this called? Can I use this for checking the existing invoice?
The NO. column you're showing in your screenshot is the DocNumber field. It's in the documentation here:
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/invoice#the-invoice-object
In most cases, the DocNumber is a unique field. But not in all cases (you'll see some exceptions noted in the docs related to France and also to custom document numbers).
The best way to avoid duplicates is to keep track of what you send to QuickBooks on your end. On your end, maintain a list of what you sent to QuickBooks. Don't send it again if you've already sent it.

consolibyte | example_mysql_mirror | syncing related questions

I am using consolibyte "mysql_mirror script" for two way syncing. Till now syncing is working perfectly but there are questions related to syncing.
We want customer billing and shipping address without First Name and Last Name. Requirement is to get only customer's address that is valid and can be used in google maps API. Question is that
Is it possible through code modification or any other way to get customer's clear address.
Customer's Mobile and Website information is not synced from QBD to MySQL. Is it possible through code modification to sync this information and if yes, can you please give me direction what code modification is required to sync it.
Some tables are not synced from QBD to MySQL like "qb_unitofmeasureset". Is there any page that specifies the list of tables that wouldn't be synced?
As per my understanding if i set mode to MODE_READWRITE and use only QUICKBOOKS_OBJECT_** option for customer type, then two way sync will work correctly.
What is the purpose of other three
QUICKBOOKS_ADD_CUSTOMERTYPE',
QUICKBOOKS_QUERY_CUSTOMERTYPE'
QUICKBOOKS_IMPORT_CUSTOMERTYPE
I see these four actions for other entities as well.
Please make sure you read this first:
http://consolibyte.com/forum/viewtopic.php?id=20
And:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/web_connector/example_mysql_mirror.php
We want customer billing and shipping address without First Name and Last Name.
The data synced is the data in QuickBooks. If QuickBooks has the first/last name in it, then the data that gets synced will have the first/last name in it.
Customer's Mobile and Website information is not synced from QBD to MySQL. Is it possible through code modification to sync this information
You should refer to the QuickBooks OSR for this. If it's accessible in the OSR, you should be able to add support for it.
I think you'd have to add the fields in here:
https://github.com/consolibyte/quickbooks-php/tree/master/QuickBooks/QBXML/Schema/Object
But I'm not 100% sure.
Some tables are not synced from QBD to MySQL like "qb_unitofmeasureset". Is there any page that specifies the list of tables that wouldn't be synced?
I don't have this information anywhere, no.
What is the purpose of other three QUICKBOOKS_ADD_CUSTOMERTYPE', QUICKBOOKS_QUERY_CUSTOMERTYPE' QUICKBOOKS_IMPORT_CUSTOMERTYPE
These are used in other parts of the framework. They are NOT used with the SQL mirror code.

Getting compact information from Square Connect API

I want to load Transactions with their Items and Customer from Square Connect API (using PHP client library), but Transactions don't contain any link to their Items unless there is order_id which often tends to be null.
As mentioned in Getting item names from Square Connect API I could go back to version 1 of the API and get list of Payments which includes Items, but there is no connection to Customer.
I know I could join Transactions to Payments by using Tenders which are included in both and get all information I need that way, but it doesn't seem to be good approach (combining two versions of API just seems wrong considering old versions of other APIs tend to deprecate and shut down after some time) and it would be very inefficient for both sides (more requests + downloading duplicate data just to try to match them).
So I would like to know if there's any better way to do this or why isn't.
Ditto on this (I can't comment yet - not enough rep). FreshKDS pull these details from the API (somehow) to display items on their Kitchen Screen. However as I'm already using a cloud service like Zapier (for Woo Orders to Trello Cards) and don't want to have the additional KDS cost as it doesn't pull square orders from WooCommerce (obviously).
So I need to be able to get the Square POS new order details to also create a Trello card - which I am using as a Kitchen Screen.
In regards to the OP's question: Does anyone have any info about webhooks perhaps, or a way to pull an entire order (even if I have to clone it to a database or cloud based spreadsheet) to allow viewing or iteration of individual food/ drink items?
Cheers.

Paypal - Selling a digital product attached to a specific user?

I'm confused by the array of Paypal APIs and options out there. Can someone help me to identify a good starting point for a virtual/digital product option that can have some custom meta data associated with it? Here are my requirements:
I'm selling in-app credits/currency
I'm using PHP to integrate with Paypal
Each purchase must be able to attach some data (for example, a user ID and a product ID from my database) that will be passed back to me so I can identify which user purchased which product, so once it is verified with Paypal, I'll know how to give the digital product to the buyer.
I assumed that "Digital Goods for Express Checkout" would do the trick, since it seems designed for online/virtual/digital types of products. However, I'm having trouble finding a way to pass through the user ID and product ID with this option. I also looked at the example and library at https://github.com/thenbrent/paypal-digital-goods-php-examples but I don't see an obvious way attach this dynamic meta data.
Thanks for any help!
Actually you only want one id. Nothing more is needed. Before processing the order, you bind the id with your meta data (in a database like MySQL).
Then in the listener you can pull out the data using the id.
Hope it helped

Get the user status in WooCommerce plugin

I have a custom plugin that calls an API and adds some additional things to my orders at Woocommerce platform.
I had three scenarios before:
first time purchase, uses data submitted from the checkout form fields is used, e.g., $_POST['account_phone'], and everything went fine
subsequent purchases used the same principle
renewals used the order data from the initial orders, and acted like a single purchase is made
Now, the API has changed a bit and several new methods are available, which changes the scenario options above:
first time purchases go into two categories, new users at the API site, and existing users at the API site but new to this platform
remaining is the same
I have issue with the purchases for existing users of this site. First time purchase sends a request to the API, using the POST parameters. However, if a user is already registered, those parameters, like his cell phone number, should be read from the billing data he/she already entered. Thus, I need a way to tell the WooCommerce is this new user trying to buy something and registering, or that this is an already existing user that has his or her data entered. I can get this data from the initial order, or user's billing info, but can't figure out how to check what type of order is it and where WooCommerce should get those values from.
Thanks!
Managed to solve this via another way. The $fields['account']['account_phone'] was shown only during the registration, and simple change of that to $fields['billing']['account_phone'] makes that field "belong" to billing info, which is always shown, which is very convenient and makes no difference later when I check for input there.

Categories