Syncing digital input and analogue input

I am doing a project in which I am using a quadrature encoder and a piezoelectric sensor. Piezo sensor is attached to analogue pin of Arduino Mega 2560, while encoder is attached to the 2 digital pins. What I want is to get the exact position of the encoder when there is force on the piezo sensor. But I am unable to get the accurate results. I have been trying this for weeks. Is there any way to sync the digital and analogue inputs to give accurate results
A little help would be highly appreciated

You need to post your program so we can see how you are doing things. I don't think there should be any problem interleaving the two activities.

...R
Several Things at a Time

But I am unable to get the accurate results.

How are you measuring these results and how do you know they are not accurate?

What speed are things running at?

What is your application and why does it matter?