A jQuery library for easy working with Yandex.Metrica and Google Analytics.
- jQuery >= 1.11.1
<!-- Required libs -->
<script src="jQuery-1.11.1.min.js"></script>
<!-- jQuery.ddMetrics -->
<script src="jQuery.ddMetrics-1.0.js"></script>
//Init metrics
$.ddMetrics.init({
//TODO: Insert Yandex.Metrica counder ID or remove it
yandexMetrika_counterId: 0000,
//TODO: If Google Analitycs is not used, remove it
googleAnalytics_isEnabled: true
});
You don't need to wait while counters API will be loaded. It's no longer your problem, the library will take care about that.
//Goal without params
$.ddMetrics.reachGoal('someGoalId');
//Goal with some params
$.ddMetrics.reachGoal(
'someGoalId',
{
someParamName: 'someParamValue',
param2: 'value2'
}
);
The library initialization method.
-
params
- Desctription: The parameters.
- Valid values:
objectPlain
- Required
-
params.yandexMetrika_counterId
- Desctription: Yandex.Metrica counder ID. Just avoid it if Yandex.Metrica is not used.
- Valid values:
integer
- Default value: —
-
params.googleAnalytics_isEnabled
- Desctription: Is Google Analitycs used?
- Valid values:
integer
- Default value:
false
The method for goals reaching.
-
name
- Desctription: Goal name (ID) that will be passed to a analitycs system.
- Valid values:
string
- Required
-
params
- Desctription: Goal parameters that will be passed to a analitycs system if needed.
- Valid values:
objectPlain
- Default value: —
-
params.paramName
- Desctription: A goal parameter when key — parameter name, value — value.
- Valid values:
string
- Required